useStateValue
Overview
Type: Function
A React hook to consume either a SimpleStateManager, StateManager, or AsyncStateManager.
const state = useStateValue(stateManager)
Overloads (+4)
const state = useStateValue(stateManager, selector)
const state = useStateValue(stateManager, selector, active)
const state = useStateValue(stateManager, selector, equalityFn)
const state = useStateValue(stateManager, selector, equalityFn, active)
Parameters
stateManager— The State Manager to watch for changes.
Type:SimpleStateManager,StateManagerorAsyncStateManager
Required: Yesselector— A function that accepts the state as an argument and returns a derived value. This function does not need to be declared outside of the component function body or wrapped inuseCallback.
Type:StateSelector
Required: No — (default value:null)equalityFn— A function that compares the previous state with the upcoming state and returnstrueif they are considered equal orfalseif otherwise. Some presets are available in theEqualityobject fromcotton-box. This function does not need to be declared outside of the component function body or wrapped inuseCallback.
Type:EqualityFn
Required: No — (default value:Object.is)active— Controls whether the hook should watch for state changes and trigger component update.
Type:boolean
Required: No — (default value:true)