Skip to content

Instantly share code, notes, and snippets.

@thomasboyt
Created August 1, 2016 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasboyt/7263cecb464231133771997a60b5c1f0 to your computer and use it in GitHub Desktop.
Save thomasboyt/7263cecb464231133771997a60b5c1f0 to your computer and use it in GitHub Desktop.
const SixtyFps = React.createClass({
componentDidMount() {
this.rafCb = this.renderLoop;
window.requestAnimationFrame(this._rafCb);
},
componentWillUnmount() {
this.rafCb = () => {};
},
renderLoop() {
this.forceUpdate();
window.requestAnimationFrame(this._rafCb);
},
render() {
return this.props.children;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment