-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Concurrent Mode and UseSubscription with RxJS "lose" updates #17314
Comments
#16396 (comment) |
Started looking into why this happens - #17336 Seems like an issue somewhere in |
Maybe related: #17318 (comment) |
yes i already signaled here : #17318 (comment) |
Reported similar issue some time ago: #17028 |
Thanks for the bug report! I believe this was fixed by #18091 You can confirm using I'm going to close this issue, but if the bug persists please comment and we'll reopen. |
Rebased https://github.com/facebook/react/pull/17336/files and the test was green - thanks! |
@samcooke98 Thank you for that PR! I feel a bit guilty that it got buried and I didn't notice it. But I really appreciate that you took the time to write a unit test 😮We'll try to do a better job keeping track of our PR queue! |
No worries, was a nice learning experience |
Do you want to request a feature or report a bug?
Bug - I think?
What is the current behavior?
In Concurrent Mode, it appears that if a render is interrupted, if a component is using
useSubscription
the interrupted update is lost, which leads to "tearing"The following codesandbox uses
useSubscription
with a RxJSBehaviorSubject
, mimicking the example from here: https://www.npmjs.com/package/use-subscription#subscribing-to-observablesIn the sandbox, clicking on the "Increment Remote Count" button triggers the RxJs
BehaviorSubject
to increment. This is done outside of the React event handler (ie: viawindow.addEventLIstener
and so the updates are not batched together. The update to render the numbers is artificially slowed down.If you click the "Increment Remote Count" button multiple times, the update works as expected.
If you interrupt the update, via clicking the "increment local count", only the last number will update.
So the Steps to reproduce look like:
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
https://jwenc.csb.app/ \ https://codesandbox.io/s/usesubscriptionconcurrentlosingupdates-jwenc
What is the expected behavior?
I'd expect there to be a commit as the above screenshot, but I'd then expect there to be a follow-up commit that restores the consistency. In other words, I'd expect in the above picture for everything to be
1
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
0.0.0-experimental-f6b8d31a7
I'd be willing to try to take a stab at writing a React test for this, if needed?
The text was updated successfully, but these errors were encountered: