Skip to main content

components/provider/SCUserProvider

Variables

SCUserContext

const SCUserContext: Context <SCUserContextType>

SCUserContext (Authentication Context)

Context can be consumed in one of the following ways:
1. <SCUserContext.Consumer>{(user, session, error, loading, logout) => (...)}</SCUserContext.Consumer>
2. const scUserContext: SCUserContextType = useContext(SCUserContext);
3. const scUserContext: SCUserContextType = useSCUser();

Source

packages/react-core/src/components/provider/SCUserProvider/index.tsx:50

Functions

SCUserProvider()

SCUserProvider(children): JSX.Element

Description:

This component keeps current user logged and session; it is exported as we need to wrap the entire app with it

Parameters

ParameterTypeDescription
childrenobject
children.childrenReactNode-

Returns

JSX.Element

<SCUserContext.Provider value={contextValue}>{!state.loading && children}</SCUserContext.Provider>

Source

packages/react-core/src/components/provider/SCUserProvider/index.tsx:61


useSCUser()

useSCUser(): SCUserContextType

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

Returns

SCUserContextType

Source

packages/react-core/src/components/provider/SCUserProvider/index.tsx:301