diff --git a/components/space/Item.tsx b/components/space/Item.tsx index e4f89f91c8..a99db877d9 100644 --- a/components/space/Item.tsx +++ b/components/space/Item.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { SpaceContext } from '.'; +import { SpaceContext } from './context'; export interface ItemProps { className: string; diff --git a/components/space/context.ts b/components/space/context.ts new file mode 100644 index 0000000000..eba94e542a --- /dev/null +++ b/components/space/context.ts @@ -0,0 +1,10 @@ +import React from 'react'; + +export const SpaceContext = React.createContext({ + latestIndex: 0, + horizontalSize: 0, + verticalSize: 0, + supportFlexGap: false, +}); + +export const SpaceContextProvider = SpaceContext.Provider; diff --git a/components/space/index.tsx b/components/space/index.tsx index a12f1753cd..dcae2d661c 100644 --- a/components/space/index.tsx +++ b/components/space/index.tsx @@ -7,14 +7,10 @@ import type { SizeType } from '../config-provider/SizeContext'; import Compact from './Compact'; import Item from './Item'; +import { SpaceContextProvider } from './context'; import useStyle from './style'; -export const SpaceContext = React.createContext({ - latestIndex: 0, - horizontalSize: 0, - verticalSize: 0, - supportFlexGap: false, -}); +export type { SpaceContext } from './context'; export type SpaceSize = SizeType | number; @@ -159,7 +155,7 @@ const Space = React.forwardRef((props, ref) => { }} {...otherProps} > - {nodes} + {nodes} , ); });