Skip to content
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

(react) - Update initial state to not require abort on mount #2227

Merged
merged 2 commits into from
Jan 31, 2022

Conversation

kitten
Copy link
Member

@kitten kitten commented Jan 31, 2022

Resolve #2226

Summary

Previously, the useSyncExternalStore reimplementation regressed
on us constructing the correct initial state on mount, and instead
relied on an abort on mount, which is confusing to users.
Instead, we can simply revert to what we've done prior to the
change and ensure that the initial state is accurate.

This fix does not change any of the current behaviour, but simply avoids the confusing state transition on mount.

Set of changes

  • Update initial state in useQuery implementation

Previously, the `useSyncExternalStore` reimplementation regressed
on us constructing the correct initial state on mount, and instead
relied on an abort on mount, which is confusing to users.
Instead, we can simply revert to what we've done prior to the
change and ensure that the initial state is accurate.
@kitten kitten requested a review from JoviDeCroock January 31, 2022 12:20
@changeset-bot
Copy link

changeset-bot bot commented Jan 31, 2022

🦋 Changeset detected

Latest commit: 5667bff

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
urql Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

suspense: boolean;
}>({
source: null,
}>(() => ({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't strictly speaking necessary, but let's avoid calling client.executeQuery on every render 😆

@kitten kitten merged commit b79986a into main Jan 31, 2022
@kitten kitten deleted the fix/initial-use-query-state branch January 31, 2022 12:53
@urql-ci urql-ci mentioned this pull request Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(react) - Fetching initial value is false on first mount
2 participants