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:52
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
Parameter | Type | Description |
---|---|---|
children | object | |
children.children | ReactNode | - |
Returns
JSX.Element
<SCUserContext.Provider value={contextValue}>{!state.loading && children}</SCUserContext.Provider>
Source
packages/react-core/src/components/provider/SCUserProvider/index.tsx:63
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
Source
packages/react-core/src/components/provider/SCUserProvider/index.tsx:308