ReactJS renders multiple ThreeJS canvases on save

Oscar de la Hera Gomez
Two flowers that represent ReactJS and ThreeJS side by side. Beneath them sits the text "ReactJS & ThreeJS Error: Multiple Canvases on Hot Reload."

To resolve ReactJS rendering an additional canvas every time a hot reload takes place, remove the renderer from the scenes ref when the component unmounts.

The solution for this issue can be found in our Open Source React-Redux Starter Project on the tutorial/three-js/starter branch.

git clone git@github.com:delasign/react-redux-starter-project.git

A screenshot of Chrome highliting how an extra canvas have been added to the website after making a code change when we intended for only one to remain present.

An example of ReactJS rendering an additional after a code change.

The error that this article covers is how to make sure that ReactJS does not render an additional canvas every time a change is made to a ReactJS file.

To resolve this, make sure that you remove the renderer from the ref of the scene.

Looking to learn more about ReactJS and ThreeJS ?

Search our blog to find educational content on learning how to use ReactJS and ThreeJS.

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
delasign logo

Book a Free Consultation.

An icon of an email.

Click here to email us.

Fill in the details below to book a free consultation or to let us know about something else. Whatever it is, we are here to help.

How can we help you ?

Contact Details