UseModel
useModel
Hook.
Consumes the selectors and wraps actions.
useModel(selectors: Map<Selectors>, actions: Map<ActionCreator>, props: Object)
Usage
Injects selectorProps, wrapped actionProps and the instanceId.
const { count, add } = useModel({count: getters.count,}, {add: actions.add,}, {instanceId: "customInstanceId"})
Params
selectors: Map<SelectorFunction> | null
The
selectors
that will consume the state from the parent module.Each key of the
selectors
Map will be executed against the module store.actions: Map<ActionCreator> | null
Each key of the
actions
Map will be wrapped with module dispatch function.props: Object
An
instanceId
passed by props to the hook will take precedence over the contextinstanceId
.
Return value
ModelProps: {...selectorProps: Map<Any>,...wrappedActionProps: Map<Dispatch<ActionCreator>>,instanceId: String}