@jonstuebe/react-redux-middleware
v0.1.3
Published
react-redux that runs on setState and the new react context api
Downloads
5
Readme
React Redux Middleware
This is two basic middlewares for the all React api driven react-redux
Install
npm
npm i -s @jonstuebe/react-redux-middleware
or yarn
yarn add @jonstuebe/react-redux-middleware
Importing
ES6
import { logger, thunk } from "@jonstuebe/react-redux-middleware";
ES5 (CommonJS)
const { logger, thunk } = require("@jonstuebe/react-redux-middleware");
ES5 (UMD Build)
var thunk = ReactReduxMiddleware.thunk;
var logger = ReactReduxMiddleware.logger;
Usage
thunk
Just like redux, react-redux does not handle async action creators as those can be handled by middleware. Thus thunk.
Writing thunks
const thunk = (a, b) => {
return dispatch => {
setTimeout(() => {
dispatch({
type: "TEST",
a,
b
});
}, 3000);
};
};
logger
By adding the logger you'll get very basic logging in your console.