@codewell/state-actions
v1.0.1
Published
## Installation ``` npm install @codewell/state-actions ```
Downloads
6
Readme
@codewell/state-actions
Installation
npm install @codewell/state-actions
Basic usage
Set state property
Setting a state property overrides the current value of a state property.
import { setStateProperty } from '@codewell/state-actions';
const state = { foo: 'foo' };
const actoin = { payload: 'bar' };
setStateProperty(state, action, 'foo');
// => {foo: 'bar'}
Update state property
Updates some (or all) fields of a state property.
import { updateStateProperty } from '@codewell/state-actions';
const state = { foo: {
one: 1,
two: 0,
} };
const actoin = { payload: {two: 2, three: 3} };
updateStateProperty(state, action, 'foo');
// => {foo: {one: 1, two: 2, three: 3}}
Remove state property
Removes a property from the state.
import { removeStateProperty } from '@codewell/state-actions';
const state = { foo: 'foo' };
removeStateProperty(state, 'foo');
// => {}