Dat.Gui produces multiple GUI's on hot reload in ReactJS

To ensure that only one dat.gui is seen on hot reload, destroy the gui in the componentWillUnmount event within a useEffect hook.

Oscar de la Hera Gomez
Written by Oscar de la Hera Gomez
First published on 11/16/2023 at 16:22
Last Updated on 11/16/2023 at 20:41
<p>Two flowers that represent ReactJS and ThreeJS side by side. Beneath them sits the text "dat.gui Error: Multiple GUIs."</p>

To ensure that only one dat.gui is seen on hot reload, destroy the gui in the componentWillUnmount event within a useEffect hook.

SubscribeReact, ThreeJS & GLSL Resources
<p>A screenshot of Chrome showing multiple, identical GUI's within a ThreeJS (3JS) scene.</p>

In order to prevent ReactJS from generating multiple, identical GUI's on hot reload, you must destroy the GUI in the componentWillUnmount event within a useEffect hook.

To learn how to do this consult the tutorial below.

How to use dat.gui with ReactJS and ThreeJS
<p>A screenshot of VSCode showing you how to update the useEffect function to setup the GUI and to destroy it to avoid errors on hot reload.</p>

Looking to learn more about ReactJS and ThreeJS ?

Search our blog to find educational content on learning how to use ReactJS and ThreeJS.
Search our BlogReact, ThreeJS & GLSL Resources

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.
SubscribeContact UsVisit our BlogView our ServicesView our Work

Partner with us

We would love to get to know you and see how we can help your organization with its goals and needs.
Let's Talk

Stay Informed

Get occasional updates about our company, research, and product launches.
Subscribe