fix: use useSyncExternalStore in the useStateStore hook #3084
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The goal of the PR is inspired by GetStream/stream-chat-react#2573. I was trying to reply to a message where I noticed that when replying to a poll message, and then if you reply to some other message, the poll message doesn't go away from the UI, and that is because of https://github.com/GetStream/stream-chat-react-native/blob/develop/package/src/components/Reply/Reply.tsx#L180 not resetting as it should. React added this change in the past to the
useStateStorehook they have, which we never added to fix a similar bug. This is a possible fix to the issue, as previously changing the store in the hook would keep the previously calculated state and return it.Prev
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-05-13.at.10.36.13.mp4
Now
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-05-13.at.10.35.48.mp4