mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-22 06:18:30 +08:00
9b49fb60d9
close #12985
26 lines
657 B
TypeScript
26 lines
657 B
TypeScript
import * as React from 'react';
|
|
import createReactContext, { Context } from 'create-react-context';
|
|
|
|
export interface ConfigProviderProps {
|
|
getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement;
|
|
}
|
|
|
|
const ConfigContext: Context<ConfigProviderProps | null> = createReactContext({});
|
|
|
|
const ConfigProvider: React.SFC<ConfigProviderProps> = (props) => {
|
|
const { getPopupContainer, children } = props;
|
|
const config = {
|
|
getPopupContainer,
|
|
};
|
|
|
|
return (
|
|
<ConfigContext.Provider value={config}>
|
|
{children}
|
|
</ConfigContext.Provider>
|
|
);
|
|
}
|
|
|
|
export const ConfigConsumer = ConfigContext.Consumer;
|
|
|
|
export default ConfigProvider;
|