useRender causes the canvas objects to render 3 times on mount
See original GitHub issueI’ve noticed when using useRender the objects render 3 times on mount. https://codesandbox.io/s/kk2z0okjq3
function RenderTest() {
console.log('render')
useRender(() => true)
return (
<mesh>
<icosahedronBufferGeometry attach="geometry" args={[1, 0]} />
<meshNormalMaterial attach="material" />
</mesh>
)
}
function App() {
return (
<Canvas>
<RenderTest />
</Canvas>
)
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
useRender causes the canvas objects to render 3 times on ...
I've noticed when using useRender the objects render 3 times on mount. https://codesandbox.io/s/kk2z0okjq3 function RenderTest() ...
Read more >Model gets rendered multiple times when using useGLTP from ...
I am using react three fiber and drei for getting and loading GLB file from server. It's working with the below code but...
Read more >Common mistakes to avoid while working with Vue.js
Looking for a front-end framework to try out, I started with React and then tried Vue.js. Unfortunately, I encountered a lot of issues...
Read more >Performance pitfalls - React Three Fiber Documentation
The most important gotcha in three.js is that creating objects can be expensive, think twice before you mount/unmount things! Every material or light...
Read more >React Hooks - Understanding Component Re-renders - Medium
#1, 2, 3: Upon mounting, Component is rendered with default ticker ('AAPL'). #4: useEffect handler ran the first time after the mount —...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@arif-hanif components should never rely on render cycles, you just can’t know if a parent re-renders for any reason, it could call setState in an interval if it wanted, components need to be impervious to it. If you have a calculation that’s being precessed more than once you need to use useMemo.
The issue is otherwise easy to fix, i’m just not sure in what manner because it will be a breaking change which needs a new major. But it still shouldn’t cause any app related problems right now.
i am running into the same issue with 3 renders so any computations on the scenes get called 3 times.