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: Context.Consumer inside Suspense does not receive context updates while suspended
#19701
Labels
Comments
|
Can you turn this into a failing test, like we did for #17356? |
overlookmotel
added a commit
to overlookmotel/react
that referenced
this issue
Aug 26, 2020
overlookmotel
added a commit
to overlookmotel/react
that referenced
this issue
Aug 26, 2020
overlookmotel
added a commit
to overlookmotel/react
that referenced
this issue
Aug 26, 2020
|
@overlookmotel and @gaearon This is looking abandoned. Can I take a look at it? |
|
@engprodigy I've submitted PR #19702 with a failing test. Personally, I'd very much appreciate your input if you have any ideas for a fix. |
|
Sure @overlookmotel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

A
<Context.Consumer>callback inside a suspended<Suspense>boundary does not receive updates when context value changes.This issue was originally found with React Router (remix-run/react-router#7137) but can be reproduced with React alone.
React version: 16.13.1 or 17.0.0-rc.0 (and at least some earlier versions too)
Steps To Reproduce
https://codesandbox.io/s/suspense-context-test-case-6jlsq
The current behavior
In the example above, clicking on the "About" button puts the
<Suspense>boundary into a suspended state. Clicking "Home" updates the context value, but the<Context.Consumer>callback is not called with this updated value. Therefore the page never navigates back to "Home".Please note that
Received context: homeis not logged after the "Home" button is pressed.The expected behavior
The
<Context.Consumer>callback should be called with value'home'when the value of the context is updated.Please note that the problem does not occur if any of:
Aboutfunction to verify).useContext()is used in place of<Context.Consumer>(substitute<SwitchWithUseContext />for<Switch />).Switchfunction is inlined within the<Suspense>rather than in a separate component.The last of these leads me to suspect that the problem may be related to #17356. In the example,
<Context.Consumer>is within aSwitchcomponent. But the<Switch>element inside<Suspense>never changes - so it's effectively memoized. I wonder if this is why it doesn't receive context updates?The text was updated successfully, but these errors were encountered: