withAuthUser¶
Deprecated Higher-order components are not commonly used in modern React code, use Hooks instead
Import¶
Function Signature¶
withAuthUser<T
, P
>(Component
): React.FunctionComponent
<P
>
Type Parameters¶
Name | Type | Description |
---|---|---|
T |
T |
Type of User State Object |
P |
extends withAuthStateProps <T > |
Props of the component |
Parameters¶
Name | Type | Description |
---|---|---|
Component |
ComponentType <P > |
React Class based Component |
Returns¶
React.FunctionComponent
<P
>
React Higher Order Component with injected authState
prop
React HOC that injects the user state into the class-based component props
If the prop is null then the user may be not authenticated.
Use isAuthenticated
to verify
Example¶
class MyComponent extends React.Component {
render() {
return <h1>Hello, {this.props.authState}</h1>;
}
}
export default withAuthUser(MyComponent);
Throws¶
AuthError - Thrown if the Hook is used outside the Provider Scope.
Defined in¶
higherOrderComponents/withAuthUser.tsx
— 🔑 —
React Auth Kit is MIT License code