Skip to content

ariesjia/use-reducer-middlewares

Repository files navigation

use-reducer-middlewares

enhance React Hooks API useReducer can use middleware.

NPM Build Status minified license coverage

Install

// use yarn
yarn add use-reducer-middlewares
// use npm
npm install use-reducer-middlewares

Demo

import useMiddleWares from 'use-reducer-middlewares'
import logger from 'redux-logger'

const reducer = function (state, action) {
  // reducer
  return state
}

const init = function(count) {
  return {count}
}

const [state, dispatch] = useMiddleWares(reducer, 1, init)([
  logger
]);

Sandbox Demo

(Code Sandbox Demo)[https://codesandbox.io/s/wk3o2jp1ll]