import * as React from 'react'; import { ThemeType } from './type'; import { ThemeContext } from './theme.context'; import { defaultTheme } from '../style'; import deepmerge from 'deepmerge'; export interface ThemeProviderProps { theme?: ThemeType; children: React.ReactNode; } export const ThemeProvider: React.FunctionComponent = ( props ) => { const { theme: themeProp = {}, children } = props; const [themeState, setThemeState] = React.useState( deepmerge(defaultTheme, themeProp) ); const setTheme = (newTheme: ThemeType) => { const mergedTheme = deepmerge(defaultTheme, newTheme); setThemeState(mergedTheme); }; return ( {children} ); };