Skip to main content

components/provider/SCLocaleProvider

Variables

SCLocaleContext

const SCLocaleContext: Context<SCLocaleContextType>

Creates Global Context

Context can be consumed in one of the following ways:
1. <SCLocaleContext.Consumer>{(locale,) => (...)}</SCLocaleContext.Consumer>
2. const scLocaleContext: SCLocaleContextType = useContext(SCLocaleContext);
3. const scLocaleContext: SCLocaleContextType = useSCLocale();

Functions

SCLocaleProvider()

SCLocaleProvider(children): Element

Description:

This component makes the intl available down the React tree.

Parameters

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

Returns

Element

<SCLocaleContext.Provider value={{locale, messages, selectLocale}}>

useSCLocale()

useSCLocale(): SCLocaleContextType

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

Returns

SCLocaleContextType


withSCLocale()

withSCLocale(Component): (props) => Element

Export hoc to inject the base theme to components

Parameters

ParameterTypeDescription
Componentany

Returns

(props): Element

Parameters
ParameterType
propsany
Returns

Element