react-worker
v1.0.0
Published
react in a web worker
Downloads
85
Maintainers
Readme
react-worker
install
npm install --save react-worker
usage
on the main thread:
var React = require('react-worker/src/host');
React.render(require('worker!./worker'), document.getElementById('root'));
on the worker:
var React = require('react-worker/src/client');
var App = React.createClass({
getInitialState: function() {
return {
i: 0
};
},
componentDidMount: function() {
this.interval = setInterval(this.tick, 16);
},
componentWillUnmount: function() {
clearInterval(this.interval);
},
tick: function tick() {
this.setState({
i: this.state.i + 1
});
},
render: function render() {
return React.createElement('ul', null, React.createElement('li', null, this.state.i));
}
});
React.render(<App />);
license
BSD-3-Clause