react-redux-action-subscribe
v0.0.4
Published
Add an action listener with react hooks
Downloads
5
Readme
react-redux-action-subscribe
Add an action listener with react hooks
Install
npm install --save react-redux-action-subscribe
Usage
Redux Store
import { createStore, applyMiddleware } from 'redux';
import actionMiddleware from 'react-redux-action-subscribe';
import reducers from './reducers';
const store = createStore(reducers, initialState, applyMiddleware(actionMiddleware));
Component
import React, { Component } from 'react'
import { useActionSubscribe } from 'react-redux-action-subscribe'
function Example {
// case 1
useActionSubscribe({
addItem: (action) => {
}
});
// case 2
useActionSubscribe('removeItem', (action) => {
});
return <MyComponent />
}
License
MIT © pyjun01