Skip to content

Bug: unstable_useMutableSource throws error when mutated before subscribe #19948

@SreeniIO

Description

@SreeniIO

React version: 0.0.0-experimental-94c0244ba

Steps To Reproduce

Mutating the external source during the initial render before subscribe throws error.

https://codesandbox.io/s/usemutablesource-7nbs6?file=/src/App.js

image

  1. Navigate to the above code sandbox
  2. Click on the Mutate button. Final Value is rendered without any error. (Success Mode)
  3. Toggle to Error Mode and click on the Mutate button again.
  4. Error thrown (and the UI is rendered with the Final Value when run from vscode)

Note: In our actual codebase (private), we are seeing this error at different instances e.g. component getting updated due to setState call in useLayoutEffect etc.

The current behavior

Seeing errors in development build.

image

The expected behavior

These errors thrown by useMutableSource should not showup on the UI and not passed to the error boundary as the component is eventually re-rendered with the latest state without any error.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions