useReduxState()
This hook allows to create redux state at runtime.
or
returns{}
#
config
#
#
path''type: string
default: Date().getTime()
nestable key path of the redux state
#
state?type: any
initial state
#
reducer()?type: function
function that takes the current state
for the given path, payload
and returns computed new state.
this function runs once during the initialization of the state
use the function when you want to manually handle how the state should be created/updated.
in the above example reducer had prevented from over-writing the store state when there is an existing value for the state. instead of:
we got:
#
unmount?type: boolean default: false
determines whether redux state should mount
#
cleanup?type: boolean
determines whether redux state should cleanup the state when component unmounted from view.
Example
#
#
Apis#
getStatefunction to get states for a given state path in the redux store.
Arguments
#
#
selectorPathselector function or path of the nest-able state to be selected
Returns
#
#
stateValueor
Example
#
#
setStatefunction to update states in the redux store.
Arguments
#
#
payload|setter()?(payload) value to set in the state or (setter) function to determine how the state should be set.