Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Dropped update when render phase update happens before suspending #18486

Closed
gaearon opened this issue Apr 4, 2020 · 2 comments · Fixed by #18537
Closed

Bug: Dropped update when render phase update happens before suspending #18486

gaearon opened this issue Apr 4, 2020 · 2 comments · Fixed by #18537

Comments

@gaearon
Copy link
Collaborator

gaearon commented Apr 4, 2020

Sandbox: https://codesandbox.io/s/cranky-kapitsa-op3jh

Repro: type "a" and then after a second "b"

Expected: Eventually you'll see "ab" in all fields. Pending "..." indicator goes away.

Actual: You'll keep seeing "a" in low pri field. Pending "..." indicator is stuck.

@gaearon gaearon added Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Component: Suspense Type: Bug and removed Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug labels Apr 4, 2020
@VakoNonikashvili
Copy link

VakoNonikashvili commented Apr 4, 2020

Sandbox: https://codesandbox.io/s/nostalgic-gauss-xrn4o (If I understand problem correctly)

Why didn't you update mirror text with useEffect?

@gaearon
Copy link
Collaborator Author

gaearon commented Apr 4, 2020

Generally saying, render phase updates are better for derived state because you don’t need an extra rendering pass for the whole subtree.

In either case, it doesn’t matter how else I could write it. The problem is that this uncovers a bug in React, and bugs need to be fixed.

gaearon added a commit to gaearon/react that referenced this issue Apr 7, 2020
acdlite added a commit to acdlite/react that referenced this issue Apr 8, 2020
acdlite pushed a commit to acdlite/react that referenced this issue Apr 8, 2020
acdlite added a commit that referenced this issue Apr 8, 2020
…t to be dropped (#18537)

* Bugfix: Render phase update leads to dropped work

Render phase updates should not affect the `fiber.expirationTime` field.
We don't have to set anything on the fiber because we're going to
process the render phase update immediately.

We also shouldn't reset the `expirationTime` field in between render
passes because it represents the remaining work left in the update
queues. During the re-render, the updates that were skipped in the
original pass are not processed again.

I think my original motivation for using this field for render phase
updates was so I didn't have to add another module level variable.

* Add repro case for #18486

Co-authored-by: Dan Abramov <dan.abramov@me.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants