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();

Functions

SCUserProvider()

SCUserProvider(children): 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
children{ children: ReactNode; }
children.childrenReactNode-

Returns

Element

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

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