Browse Source

refactor: resolve useSize circular reference (#42810)

pull/43169/head
Zack Chang 1 year ago
committed by GitHub
parent
commit
5827f9ddef
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      components/config-provider/SizeContext.tsx

5
components/config-provider/SizeContext.tsx

@ -1,5 +1,4 @@
import * as React from 'react';
import useSize from './hooks/useSize';
export type SizeType = 'small' | 'middle' | 'large' | undefined;
@ -11,8 +10,8 @@ export interface SizeContextProps {
}
export const SizeContextProvider: React.FC<SizeContextProps> = ({ children, size }) => {
const mergedSize = useSize(size);
return <SizeContext.Provider value={mergedSize}>{children}</SizeContext.Provider>;
const originSize = React.useContext<SizeType>(SizeContext);
return <SizeContext.Provider value={size || originSize}>{children}</SizeContext.Provider>;
};
export default SizeContext;

Loading…
Cancel
Save