Skip to main content

components/provider/SCPreferencesProvider

Variables

SCPreferencesContext

const SCPreferencesContext: Context <SCPreferencesContextType>

Creates Preferences/Features Context

Context can be consumed in one of the following ways:
1. <SCPreferencesContext.Consumer>{(preferences) => (...)}</SCPreferencesContext.Consumer>
2. const scPreferences: SCPreferencesType = useContext(SCPreferencesContext);
3. const scPreferences: SCPreferencesType = useSCPreferences();

Source

packages/react-core/src/components/provider/SCPreferencesProvider/index.tsx:25

Functions

SCPreferencesProvider()

SCPreferencesProvider(children): JSX.Element

Description:

This component imports all preferences and features enabled.

Parameters

ParameterTypeDescription
childrenobject
children.childrenReactNode-

Returns

JSX.Element

 <SCPreferencesContext.Provider value={{preferences, features}}>{!loading && children}</SCPreferencesContext.Provider>

Source

packages/react-core/src/components/provider/SCPreferencesProvider/index.tsx:36


useSCPreferences()

useSCPreferences(): SCPreferencesContextType

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

Returns

SCPreferencesContextType

Source

packages/react-core/src/components/provider/SCPreferencesProvider/index.tsx:93