Skip to content
This repository was archived by the owner on May 15, 2022. It is now read-only.
This repository was archived by the owner on May 15, 2022. It is now read-only.

Why do a deep clone in update? #58

@disambiguator

Description

@disambiguator

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions