Module: 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();
Defined in
components/provider/SCUserProvider/index.tsx:43
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
Name | Type |
---|---|
children | Object |
children.children | ReactNode |
Returns
JSX.Element
<SCUserContext.Provider value={contextValue}>{!state.loading && children}</SCUserContext.Provider>
Defined in
components/provider/SCUserProvider/index.tsx:54
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.