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:
import { useNullableState } from '@oneblink/apps-react'const startingProfile = { name: 'Forest Gump', profession: 'Military, Athlete, Other',}const [userProfile, setUserProfile, unsetUserProfile] = useBooleanState(startingProfile) Copy
import { useNullableState } from '@oneblink/apps-react'const startingProfile = { name: 'Forest Gump', profession: 'Military, Athlete, Other',}const [userProfile, setUserProfile, unsetUserProfile] = useBooleanState(startingProfile)
setUserProfile can then be called with an object of type T like:
setUserProfile
T
setUserProfile({ name: 'Walter White', profession: 'Chemistry Teacher (Secondary School), Other',}) Copy
setUserProfile({ name: 'Walter White', profession: 'Chemistry Teacher (Secondary School), Other',})
And unsetUserProfile can be called like:
unsetUserProfile
unsetUserProfile() Copy
unsetUserProfile()
The type of the state
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: