Skip to main content

components/provider/SCThemeProvider

Variables

SCThemeContext

const SCThemeContext: Context<SCThemeContextType>

Creates Global Context

Context can be consumed in one of the following ways:
1. <SCThemeContext.Consumer>{(theme,) => (...)}</SCThemeContext.Consumer>
2. const scThemeContext: SCThemeContextType = useContext(SCThemeContext);
3. const scThemeContext: SCThemeContextType = useSCTheme();

Functions

SCThemeProvider()

SCThemeProvider(children): Element

Description:

This component makes the theme available down the React tree. It should preferably be used at the root of your component tree. See: https://mui.com/system/styled/

Parameters

ParameterTypeDescription
children{ children: ReactNode; }
children.childrenReactNode-

Returns

Element

<SCThemeContext.Provider value={{theme, setTheme: setCustomTheme}}>
<ThemeProvider theme={theme}>{children}</ThemeProvider>
</SCThemeContext.Provider>

useSCTheme()

useSCTheme(): SCThemeContextType

Let's only export the useSCTheme hook instead of the context. We only want to use the hook directly and never the context component.

Returns

SCThemeContextType


withSCTheme()

withSCTheme(Component): (props) => Element

Export hoc to inject the base theme to components

Parameters

ParameterTypeDescription
Componentany

Returns

(props): Element

Parameters
ParameterType
propsany
Returns

Element