Flux Standard Action utilities for Redux.
See the codeFlux Standard Action utilities for Redux
$ npm install --save redux-actions
or
$ yarn add redux-actions
The npm package provides ES modules that should be compatible with every modern build tooling.
import { createActions, handleActions, combineActions } from 'redux-actions';
const defaultState = { counter: 10 };
const { increment, decrement } = createActions({
INCREMENT: (amount = 1) => ({ amount }),
DECREMENT: (amount = 1) => ({ amount: -amount })
});
const reducer = handleActions(
{
[combineActions(increment, decrement)]: (
state,
{ payload: { amount } }
) => {
return { ...state, counter: state.counter + amount };
}
},
defaultState
);
export default reducer;
See the full API documentation.
Overall
Maintained
Code review
Latest release
Releases this year
(top 24 of 32)
148 followers · starred May 2016
3,401 followers · starred Jun 2018
206 followers · starred Jul 2018
166 followers · starred Sep 2016
Flux Standard Action utilities for Redux.
See the codeFlux Standard Action utilities for Redux
$ npm install --save redux-actions
or
$ yarn add redux-actions
The npm package provides ES modules that should be compatible with every modern build tooling.
import { createActions, handleActions, combineActions } from 'redux-actions';
const defaultState = { counter: 10 };
const { increment, decrement } = createActions({
INCREMENT: (amount = 1) => ({ amount }),
DECREMENT: (amount = 1) => ({ amount: -amount })
});
const reducer = handleActions(
{
[combineActions(increment, decrement)]: (
state,
{ payload: { amount } }
) => {
return { ...state, counter: state.counter + amount };
}
},
defaultState
);
export default reducer;
See the full API documentation.
Overall
Maintained
Code review
Latest release
Releases this year
(top 24 of 32)
148 followers · starred May 2016
3,401 followers · starred Jun 2018
206 followers · starred Jul 2018
166 followers · starred Sep 2016