ant-design/components/config-provider/index.tsx
2018-12-07 18:27:30 +08:00

22 lines
631 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;