question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useRender causes the canvas objects to render 3 times on mount

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
drcmdacommented, Apr 12, 2019

@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.

0reactions
arif-hanifcommented, Apr 11, 2019

i am running into the same issue with 3 renders so any computations on the scenes get called 3 times.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found