Browse Source

refactor: solve list circluar dependency issue (#42806)

pull/42841/head
kiner-tang(文辉) 1 year ago
committed by GitHub
parent
commit
ceda8fb7c4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      components/list/Item.tsx
  2. 10
      components/list/context.ts
  3. 17
      components/list/index.tsx

4
components/list/Item.tsx

@ -9,10 +9,10 @@ import type {
ReactNode,
} from 'react';
import React, { Children, forwardRef, useContext } from 'react';
import { cloneElement } from '../_util/reactNode';
import { ConfigContext } from '../config-provider';
import { Col } from '../grid';
import { cloneElement } from '../_util/reactNode';
import { ListContext } from './index';
import { ListContext } from './context';
export interface ListItemProps extends HTMLAttributes<HTMLDivElement> {
className?: string;

10
components/list/context.ts

@ -0,0 +1,10 @@
import React from 'react';
export interface ListConsumerProps {
grid?: any;
itemLayout?: string;
}
export const ListContext = React.createContext<ListConsumerProps>({});
export const ListConsumer = ListContext.Consumer;

17
components/list/index.tsx

@ -1,6 +1,9 @@
import classNames from 'classnames';
// eslint-disable-next-line import/no-named-as-default
import * as React from 'react';
import extendsObject from '../_util/extendsObject';
import type { Breakpoint } from '../_util/responsiveObserver';
import { responsiveArray } from '../_util/responsiveObserver';
import { ConfigContext } from '../config-provider';
import DefaultRenderEmpty from '../config-provider/defaultRenderEmpty';
import { Row } from '../grid';
@ -9,15 +12,14 @@ import type { PaginationConfig } from '../pagination';
import Pagination from '../pagination';
import type { SpinProps } from '../spin';
import Spin from '../spin';
import type { Breakpoint } from '../_util/responsiveObserver';
import { responsiveArray } from '../_util/responsiveObserver';
import extendsObject from '../_util/extendsObject';
import Item from './Item';
// CSSINJS
import { ListContext } from './context';
import useStyle from './style';
export type { ListItemMetaProps, ListItemProps } from './Item';
export type { ListConsumerProps } from './context';
export type ColumnCount = number;
@ -66,15 +68,6 @@ export interface ListLocale {
emptyText: React.ReactNode;
}
export interface ListConsumerProps {
grid?: any;
itemLayout?: string;
}
export const ListContext = React.createContext<ListConsumerProps>({});
export const ListConsumer = ListContext.Consumer;
function List<T>({
pagination = false as ListProps<any>['pagination'],
prefixCls: customizePrefixCls,

Loading…
Cancel
Save