Skip to content

Conversation

alessbell
Copy link
Contributor

Fixes #10361.

Uses existing canUseLayoutEffect utility in a useIsomorphicLayoutEffect util which falls back to useEffect on the server to silence the warning reported in #10361. (Using a noop instead of useEffect caused test failures even though useEffect does nothing in SSR.)

This is a stop-gap until useSuspenseQuery SSR support is built out, but a general-purpose useIsomorphicLayoutEffect will probably come in handy in the future so I opted to open this PR.

@alessbell alessbell requested a review from jerelmiller January 3, 2023 20:21
@changeset-bot
Copy link

changeset-bot bot commented Jan 3, 2023

🦋 Changeset detected

Latest commit: 567370f

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

This PR includes changesets to release 1 package
Name Type
@apollo/client 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

Copy link
Member

@jerelmiller jerelmiller left a comment

Choose a reason for hiding this comment

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

🙌 🙌 🙌 🙌

I was JUST thinking about this earlier. Thanks so much for getting to this! I had one minor question about the location of the hook, but otherwise this looks great!

@alessbell
Copy link
Contributor Author

Before/after screenshots of demo server logs (warning is no longer present):

CleanShot 2023-01-03 at 16 22 13

CleanShot 2023-01-03 at 16 22 39

@alessbell alessbell merged commit 652a1ae into release-3.8 Jan 3, 2023
@alessbell alessbell deleted the 10361-useLayoutEffect-does-nothing-on-the-server branch January 3, 2023 21:30
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants