Browse Source

refactor: solve space circular dependency issue (#42811)

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

2
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;

10
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;

10
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<HTMLDivElement, SpaceProps>((props, ref) => {
}}
{...otherProps}
>
<SpaceContext.Provider value={spaceContext}>{nodes}</SpaceContext.Provider>
<SpaceContextProvider value={spaceContext}>{nodes}</SpaceContextProvider>
</div>,
);
});

Loading…
Cancel
Save