firtoz / react-three-renderer

Render into a three.js canvas using React.
https://toxicfork.github.com/react-three-renderer-example/
MIT License
1.49k stars 155 forks source link

requestAnimationFrame error when testing #163

Closed matthova closed 7 years ago

matthova commented 7 years ago

When used with create-react-app, requestAnimationFrame throws an error.

Note basic coverage test "it('renders without crashing')" will fail as of react-three-renderer v3.1.0. Proposed solution is to wrap 'react-three-renderer/lib/React3Instance.js' line 262 in the following code:

if (typeof requestAnimationFrame === 'function') {
  this._renderRequest = requestAnimationFrame(this._render); // Line 262
}

Note, this might not be the right solution, but it did make the errors go away. @toxicFork would love to get your take on the error.

Here are the steps to recreate the error:

git clone https://github.com/matthova/React-threeJS-UI-boilerplate.git
cd React-threeJS-UI-boilerplate/
npm install
npm test
toxicFork commented 7 years ago

Thanks for the report :) I'm guessing the test fails because it doesn't use a browser with a 3d context... but it would make sense to suppress this anyway, or at least use a shim for RAF.

toxicFork commented 7 years ago

Linking #164 to it to which I have added some more comments :)