react-dat-gui icon indicating copy to clipboard operation
react-dat-gui copied to clipboard

PSA: Don't use non-persistent key for DatGui component

Open borg opened this issue 3 years ago • 0 comments

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.

borg avatar Apr 22 '21 17:04 borg