Socket
Book a DemoInstallSign in
Socket

ink-redux

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ink-redux

Redux bindings for Ink

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

ink-redux Build Status

Redux bindings for Ink.

Install

$ npm install --save ink-redux

Usage

const {h, mount, Component} = require('ink');
const {Provider, connect} = require('ink-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);

mount((
	<Provider store={store}>
		<ConnectedCounter/>
	</Provider>
));

API

See 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

Keywords

ink

FAQs

Package last updated on 09 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts