React hook for switching state on and off
npm install react-switch-state
import useSwitchState from 'react-switch-state'
const { value, setValue, switchOn, switchOff, switchOnOff } = useSwitchState()
type boolean
This is the value of the state
type (value: boolean) => void
This function is used to change the state value
type () => void
This is used for changing the state value to true
type () => void
This is used for changing the state value to false
type () => void
This is used for toggling the state value from true
to false
and vice versa
type boolean
or undefined
This is the default value that will be used for the state value.