question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suspense ping shouldn't suspend if all suspended content is already in fallback mode

See original GitHub issue

When using suspense and hooks - specifically useState and useEffect - nested async renders (using react-cache) cause state hooks not to be updated. Specifically this happens between the first promise settling and the last promise settling in a Suspense component. However the state updates concerned can be outside of the Suspense root: https://codesandbox.io/s/wznnxz9pvw

In the linked example, moving the mouse will update the displayed coordinates for the first 2000ms (the time at which the first thrown promise resolves) however, after this the UI will not show any updated coordinates until after the final nested promise in the adjacent Suspense root settles.

I may both be using Suspense wrong (given the understandable lack of documentation) as I’ve been having other bugs with this setup, specifically the above example will sometimes never render beyond the “loading …” placeholder. This is especially noticeable with setting higher timeouts in the Timeout component.

react 16.7.0-alpha react-dom 16.7.0-alpha react-cache 2.0.0-alpha

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
RichieAHBcommented, Nov 2, 2018

@aweary ah that makes sense, I guess in that instance there’s no real state to update anywhere as the state change has happened outside React (in the cache). So pinging is just a way of forcing another render with the newly fetched resource in the cache 👌🏻

1reaction
awearycommented, Nov 2, 2018

@RichieAHB a “real update” is just a regular update that occurs when you update state. I believe a ping occurs when the Promise that was thrown for a suspended components resolves or rejects, “pinging” React so that it knows to try rendering again.

@gaearon is that right?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How does SuspenseList work in React? React Source Code ...
The first branch is basically say if it has already revealed, then keep showing the content. We can see that if ForceSuspenseFallback is...
Read more >
A React component suspended while rendering, but no ...
It was using <Suspense /> element in the component but I removed it. Then application is crashed with above error. Is there any...
Read more >
react/ReactFiberBeginWork.js at main · facebook/react · GitHub
A declarative, efficient, and flexible JavaScript library for building user interfaces. - react/ReactFiberBeginWork.js at main · facebook/react.
Read more >
Use validateSuspenseListNestedChild in Playwright Internal With ...
Learn how to use validateSuspenseListNestedChild function in Playwright Internal framework for your next JavaScript automation project with LambdaTest ...
Read more >
Open Charge Point Protocol 1.6
The part of the charging process that starts when all relevant ... The Charge Point SHALL NOT modify the contents of the Authorization...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found