https://github.com/pyjun01/react-redux-action-subscribe
Add an action listener with react hooks
https://github.com/pyjun01/react-redux-action-subscribe
micro-library
Last synced: about 1 month ago
JSON representation
Add an action listener with react hooks
- Host: GitHub
- URL: https://github.com/pyjun01/react-redux-action-subscribe
- Owner: pyjun01
- Created: 2021-04-16T05:04:19.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-19T12:45:18.000Z (almost 5 years ago)
- Last Synced: 2025-10-20T00:54:24.709Z (5 months ago)
- Topics: micro-library
- Language: JavaScript
- Homepage:
- Size: 606 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-redux-action-subscribe
Add an action listener with react hooks
## Install
```bash
npm install --save react-redux-action-subscribe
```
## Usage
### Redux Store
```tsx
import { createStore, applyMiddleware } from 'redux';
import actionMiddleware from 'react-redux-action-subscribe';
import reducers from './reducers';
const store = createStore(reducers, initialState, applyMiddleware(actionMiddleware));
```
### Component
```tsx
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
}
```
## License
MIT © [pyjun01](https://github.com/pyjun01)