1.0.0 • Published 8 years ago

react-worker v1.0.0

Weekly downloads
17
License
BSD-3-Clause
Repository
github
Last release
8 years ago

react-worker

npm.io npm.io npm.io npm.io npm.io npm.io

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