ComponentState Hook
Is used to create actions
@react-state follows React and supports hooks from version 7.0.0.
In order to cretae actions you need to pass followinf parameters to useComponentState hook
Actions type
statePath (optional - if not passed then takes root)
stateIndex (optional)
Hook returns actions and new statePath which can be passed further.
const TodoDescriptionHooks = ({ statePath, stateIndex }) => {
const { actions, statePath } = useComponentState(TodoStateActions, statePath, stateIndex);
return (<div>{ actions.testTodoDescription }</div>);
};
export default React.memo(TodoDescriptionHooks);
Last updated
Was this helpful?