react-dat-gui
react-dat-gui copied to clipboard
Why do a deep clone in update?
The handle update function's behavior confuses me a little bit. Looks like the whole data object is deep cloned before setting the new property here.
The documentation in the README shows:
// Update current state with changes from controls
handleUpdate = newData =>
this.setState(prevState => ({
data: { ...prevState.data, ...newData }
}));
which I took to imply that newData would only have the updated values according to the recent event. The deep cloning has some other downstream issues, such as affecting object equality and causing a lot of unnecessary hooks to fire.
I've made a PR which changes this to instead just populate newData
with the updated key/value, it works for me locally and fixes a lot of my bugs.
https://github.com/claus/react-dat-gui/pull/57/files