-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fix issue where cache updates would not cause rerenders in useSuspenseQuery
while in strict mode
#10601
Fix issue where cache updates would not cause rerenders in useSuspenseQuery
while in strict mode
#10601
Conversation
|
/release:pr |
A new release has been made for this PR. You can install it with |
I can confirm this PR fixes the issue using the snapshot release. To test using the Spotify demo:
When on the latest alpha version, you'll notice the hear icon is not properly updated to reflect the change made. The heart should toggle on/off when liking/unliking the track but this does not occur. Using the snapshot release, perform the same process again and you'll notice the heart icon is now properly updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the case being made for this workaround—which the comment lays out very clearly 😄—and the strictMode
option will make it straightforward to add tests for these scenarios in the future 🎉
As an aside, it looks like nearly all tests still pass with strictMode: true
, with only the suspenseCount
assertions needing adjusting for obvious reasons. allows the client to be overridden
and uses default variables from the client when none provided in options
, however, look like they would either a) need further consideration or b) potentially be an indicator of a strict mode issue we should look at more closely - @jerelmiller just flagging these two tests since you surely have more insight here 👍
// for the first time by allowing React to run this effect, tear it down, | ||
// then set it back up again before we resubscribe. | ||
// | ||
// Authors note (Jerel): This feels super hacky and I hate it, but this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥲
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya......................................................
@alessbell good callout. I'm going to try those tests with a strict mode variant and ensure they work as expected. |
@alessbell I've added tests for the 2 you called out, each using strict mode: 7277274 and 44985b8. Just to confirm, do these tests satisfy what you're looking to answer, or is there something further I can test? |
@jerelmiller thanks! Yes, that answers it perfectly 🙏 |
arghhhhh. I forgot to create a changeset for this branch. I'll create a separate PR that links to this one. |
Closes #10428
Fixes an issue where using
useSuspenseQuery
would not react to cache updates while using React's strict mode.Checklist: