Skip to content

Should detect whole state spreading #5

@theKashey

Description

@theKashey

With a given code

const mapState = ({ page, direction, ...state }) => ({
  page,
  direction,
  isLoading: isLoading(state)
})

memoize state should not react to any state change, as it would.

Posible solutions:

  1. Currently, memoize react on key get, but it could react on key read. This will require all objects to be wrapped by something with valueOf/toString. They key will be added to tracking if someone "read" it, or "return" it.
    Could affect performance. Unstable.

  2. Track such situations and encourage a user to change the code

  • cast function to string, and search for spread operator (unstable)
  • detect then all keys of state used, and inform user of a potential problem. Easy to do, could be enabled by default in dev mode.

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