React: Bug: Dropped update when render phase update happens before suspending

Created on 4 Apr 2020  路  2Comments  路  Source: facebook/react

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.

Suspense Bug

Most helpful comment

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

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

All 2 comments

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

Why didn't you update mirror text with useEffect?

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

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

Was this page helpful?
0 / 5 - 0 ratings