UNPKG

react-spit

Version:

Data handling, the easy way

25 lines (20 loc) 447 B
import React from 'react'; export default event => class Spit extends React.Component { constructor(props) { super(props); event.addListener(this); this.state = { data: event.get(), } } set = data => this.setState({ data, }); render() { const { children } = this.props; return children({ data: this.state.data, set: event.set }); } componentWillUnmount() { event.removeListener(this); } }