You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
657 B

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;