react-dat-gui
react-dat-gui copied to clipboard
PSA: Don't use non-persistent key for DatGui component
Spent hours digging into issue with Slider not working properly and throwing the error
TypeError: Cannot read property 'getBoundingClientRect' of null
It would lose its sliderRef.current. In the end it turns out it was unrelated to the slider component, and instead related to me not assigning a persistent key value to the DatGui component itself. Out of habit I was using a counter to assign unique keys to components, and seemingly unless key is persistent between renders DatGui does not work as expected.
This is perhaps obvious, but it wasn't to me. If you run into this issue, here's saving you a few hours.