@@ -21,16 +21,16 @@ export const finishThemeSession = (): boolean => {
2121 return themedSession . called ;
2222} ;
2323
24- let currentTheme : any = { } ;
25-
2624export type Theme = Record < string , string | number > ;
2725
28- interface ThemeContextState {
29- theme : Theme ;
26+ export interface ThemingContextState < T extends Theme > {
27+ theme : T ;
3028 key : string | null ;
3129}
3230
33- const ThemeContext = React . createContext < ThemeContextState > ( {
31+ let currentTheme : any = { } ;
32+
33+ export const ThemingContext = React . createContext < ThemingContextState < any > > ( {
3434 theme : currentTheme ,
3535 key : null ,
3636} ) ;
@@ -43,11 +43,12 @@ export interface ThemeProviderProps<T extends Theme> {
4343
4444export function ThemeProvider < T extends Theme > ( props : ThemeProviderProps < T > ) : JSX . Element {
4545 const { children, value} = props ;
46- const currentValue = useMemo < ThemeContextState > ( ( ) => ( {
46+ const currentValue = useMemo < ThemingContextState < T > > ( ( ) => ( {
4747 theme : value as any ,
4848 key : Date . now ( ) . toString ( ) ,
4949 } ) , [ value ] ) ;
50- return React . createElement ( ThemeContext . Provider , { value : currentValue } , children ) ;
50+ currentTheme = currentValue . theme ;
51+ return React . createElement ( ThemingContext . Provider , { value : currentValue } , children ) ;
5152}
5253
5354export interface ThemeProperty < T = any > {
@@ -58,12 +59,6 @@ export interface ThemeProperty<T = any> {
5859 toString : ( ) => string ;
5960}
6061
61- export const useTheming = ( ) : ThemeContextState => {
62- const state = useContext ( ThemeContext ) ;
63- currentTheme = state . theme ;
64- return state ;
65- } ;
66-
6762export type ThemeFor < T extends ThemeSchema < any > > = T extends ThemeSchema < infer P > ? Partial < P > : never ;
6863
6964export type ThemeSchema < T extends Theme > = {
0 commit comments