@selfcommunity/react-core
Version:
React Core Components useful for integrating UI Community components (react-ui).
38 lines (35 loc) • 1.14 kB
TypeScript
import React from 'react';
import { SCUserContextType } from '../../../types';
/**
* SCUserContext (Authentication Context)
*
:::tip Context can be consumed in one of the following ways:
```jsx
1. <SCUserContext.Consumer>{(user, session, error, loading, logout) => (...)}</SCUserContext.Consumer>
```
```jsx
2. const scUserContext: SCUserContextType = useContext(SCUserContext);
```
```jsx
3. const scUserContext: SCUserContextType = useSCUser();
````
:::
*/
export declare const SCUserContext: React.Context<SCUserContextType>;
/**
* #### Description:
* This component keeps current user logged and session; it is exported as we need to wrap the entire app with it
* @param children
* @return
* ```jsx
* <SCUserContext.Provider value={contextValue}>{!state.loading && children}</SCUserContext.Provider>
* ```
*/
export default function SCUserProvider({ children }: {
children: React.ReactNode;
}): JSX.Element;
/**
* Let's only export the `useSCUser` hook instead of the context.
* We only want to use the hook directly and never the context component.
*/
export declare function useSCUser(): SCUserContextType;