Higher-order Redux reducer which returns payload for specific actions
npm install redux-payload --save
import payload from 'redux-payload';
// or
var payload = require('redux-payload');import payload from 'redux-payload/es6';Use this if you are using rollup.js or webpack 2, or any ES2015 modules-compatible bundler which can eliminate unused library code with tree-shaking.
It is recommended to import the library from redux-payload/es6 instead of
redux-payload/src because the source code depends on experimental presets from
babel (stage 1-3) and may be incompatible with your bundler or settings.
Use the Universal Module Definition (UMD)
- payload.js
- payload.min.js (minified)
payload(
actionType: String,
mapResult: ?(resultBefore: any) => resultAfter
): (reducer) => reducerCreates a higher-order reducer which returns the payload of the action
for the given action type. Before returning it maps the payload with mapResult
function, which is useful when you deal with immutable data structures in your store.