Function useNullableState
- useNullableState<T>(defaultValue): [state: T | null, setState: React.Dispatch<React.SetStateAction<T | null>>, clearState: (() => void)]
-
Returns [state: T | null, setState: React.Dispatch<React.SetStateAction<T | null>>, clearState: (() => void)]
This function is a react hook for state of type of your choosing. It comes with two memoized functions, one for setting state and one for clearing it.
The items returned in the array can be destructured and named whatever you like:
setUserProfile
can then be called with an object of typeT
like:And
unsetUserProfile
can be called like: