Rendering two times in Reactjs

My project is rendering two times from the start. Models are rendered two times, Scene is getting rendered multiple times. The whole code is in the playground. Please excuse for the console logs and comments.

Anyone have any idea how to avoid this ?

React + TS + Babylonjs

Thank you
Nikhil

Seems like a React issue to me, i.e., not related to BabylonJS. A quick Google search leads to this thread: javascript - Why is my React component is rendering twice? - Stack Overflow

If that doesn’t help… Maybe you can try to reproduce the problem with a minimal example?

1 Like

Thank you
Will take a look at that
Anyway I tried to recreate the app by importing a single model
Same issue is being recreated

Sharing code in the playground is not helping if it is not running :slight_smile:

No idea what the issue is, but you will need to reproduce this somehow otherwise we won’t be able to help.

It’s probably because you are in Strict mode - won’t happen in production. You can remove strict, but it does help you out picking up some errors.

edit: Strict Mode – React (reactjs.org)

Because the above methods might be called more than once, it’s important that they do not contain side-effects.
1 Like

Reacts strict mode is the culprit/target here. In production it is going fine.