Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vadimdemedes/ink-redux
Redux bindings for Ink
https://github.com/vadimdemedes/ink-redux
Last synced: about 4 hours ago
JSON representation
Redux bindings for Ink
- Host: GitHub
- URL: https://github.com/vadimdemedes/ink-redux
- Owner: vadimdemedes
- License: mit
- Created: 2017-07-09T20:22:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-23T04:00:24.000Z (over 7 years ago)
- Last Synced: 2024-10-29T22:38:33.770Z (about 1 month ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 42
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# ink-redux [![Build Status](https://travis-ci.org/vadimdemedes/ink-redux.svg?branch=master)](https://travis-ci.org/vadimdemedes/ink-redux)
> Redux bindings for [Ink](https://github.com/vadimdemedes/ink).
## Install
```
$ npm install redux ink-redux
```## Usage
```jsx
const {h, render, Component} = require('ink');
const {Provider, connect} = require('ink-redux');
const {createStore} = require('redux');const store = createStore((state = 0, action) => {
switch (action.type) {
case 'INCREMENT': return state + 1;
default: return state;
}
});class Counter extends Component {
render(props) {
return `Counter: ${props.counter}`;
}componentDidMount() {
this.timer = setInterval(this.props.onIncrement, 100);
}componentWillUnmount() {
clearInterval(this.timer);
}
}const mapStateToProps = state => ({
counter: state
});const mapDispatchToProps = {
onIncrement: () => ({type: 'INCREMENT'})
};const ConnectedCounter = connect(mapStateToProps, mapDispatchToProps)(Counter);
render((
));
```## API
See [react-redux](https://github.com/reactjs/react-redux) for documentation.
### Differences
- Matches API of `redux@4`
- Doesn't support `options` in `connect()`
- Doesn't support returning a function from `mapStateToProps()`## License
MIT © [Vadim Demedes](https://github.com/vadimdemedes)