Skip to content

Bug: unexpected rerender when using useMutableSource #19200

@csr632

Description

@csr632

React version: experimental

Steps To Reproduce

https://codesandbox.io/s/react-redux-usemutablesource-j1vgy

(modified from Brian Vaughn's fake react-redux demo)

  1. Increment Buttons1(update state.s1) for several times, only Label1 is rerendered, which is expected.
  2. Increment Buttons2(update state.s2), both Label1 and Label2 is rerendered, which is unexpected.

    Also notice that the unexpected render of Label1 is not commited, even when the render return value is different(since it render Math.random()).

Since Label1 return the same state.s1 from getSnapshot, Label1 should not rerendered.

This bug may lead to worse performance, because Components are rerendered for state fields that they don't need.


@bvaughn may be interested in this.
@dai-shi may also be interested in this because his use-context-selector need the correct behaviour to be efficient

Metadata

Metadata

Assignees

Labels

Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions