useEnhancedReducer
is an alternative to React.useReducer
that accepts middlewares to do some cool things before and after dispatch.
Inspired by Redux Middleware.
3-second quick look
{ const middlewares = { // do something before dispatch... // do something after dispatch... } const state dispatch = // ...}
Installation
npm install react-enhanced-reducer-hook --save
Real-world Usage
{ return { console console console }} { return { windowga && window }} { return } { } { return } { const state dispatch = return <ReactFragment> <button onClick= >+</button> <button onClick= >Reset</button> <button onClick= >-</button> <br /> Count: statecount </ReactFragment> }
Try the demo in codesanbox.