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

using Viewport onBeforeRender prop produces warning #224

Open Danathus opened 6 years ago

Danathus commented 6 years ago

When using @AndrewRayCode 's technique described in https://github.com/toxicFork/react-three-renderer/issues/43#issuecomment-326762590 re: using two <viewport>s to render a secondary subscene (potentially with different cameras), and leveraging use of the Viewport's onBeforeRender member, react-three-renderer issues the following warning in the console:

warning.js?da67:33 Warning: Foreign prop onBeforeRender found in viewport. Check the render method of 'ClassWithRenderFunction'.

Note that the behavior is as expected otherwise -- the Viewports are rendered in the order listed, each using whatever camera is referenced, and each calling any specified onBeforeRender call as listed before rendering.

I believe this shouldn't be a warning, and have an idea towards the solution. I had noticed that in the react-three-renderer source, in Viewport.js, onBeforeRender is initialized from props. However, in ViewportDescriptor.js, onBeforeRender is not referenced as a property in the code. I think that by adding this property here properly can resolve this issue so use of the property is not mistakenly flagged as a warning.