Visitar URL original
fix: use isomorphic layout effect in `useCookies` to suppress SSR warning by rr-jimmy-multani · Pull Request #949 · ItsBenCodes/cookies · GitHub
Skip to content

fix: use isomorphic layout effect in useCookies to suppress SSR warning - #949

Merged
ItsBenCodes merged 2 commits into
ItsBenCodes:mainfrom
rr-jimmy-multani:fix/use-isomorphic-layout-effect-in-use-cookies
Apr 29, 2026
Merged

ItsBenCodes merged 2 commits into
ItsBenCodes:mainfrom
rr-jimmy-multani:fix/use-isomorphic-layout-effect-in-use-cookies

Conversation

@rr-jimmy-multani

Copy link
Copy Markdown
Contributor

Problem

useCookies calls useLayoutEffect unconditionally, causing React to emit a useLayoutEffect does nothing on the server warning in every SSR-enabled app. The effect body already guards against running server-side with if (!isInBrowserEnv) return, so this is purely log noise.

Fix

Replace useLayoutEffect with an isomorphic variant that falls back to useEffect on the server — the standard pattern used by Chakra UI, MUI, Framer Motion, etc. No behaviour changes on the client.

@rr-jimmy-multani
rr-jimmy-multani marked this pull request as ready for review April 16, 2026 15:38

@ItsBenCodes ItsBenCodes left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Hi

Thank you for your PR. I apologize for the delay, my github notifications have been unreliable unless I'm tagged somehow.

I've left a few simple comment and we can merge it. Make sure to run prettier and tests. Formatting was rejected by the CI.

@rr-jimmy-multani

Copy link
Copy Markdown
Contributor Author

Hi

Thank you for your PR. I apologize for the delay, my github notifications have been unreliable unless I'm tagged somehow.

I've left a few simple comment and we can merge it. Make sure to run prettier and tests. Formatting was rejected by the CI.

Thanks @ItsBenCodes! And sorry for missing the formatting; I should have noticed that. The PR has been updated and is ready for review again.

@ItsBenCodes
ItsBenCodes merged commit 434823c into ItsBenCodes:main Apr 29, 2026
1 check passed
@rr-jimmy-multani
rr-jimmy-multani deleted the fix/use-isomorphic-layout-effect-in-use-cookies branch April 29, 2026 15:42
@ItsBenCodes

Copy link
Copy Markdown
Owner

@rr-jimmy-multani @kd-renatorodrigues fix published in v8.1.1

@rr-jimmy-multani

Copy link
Copy Markdown
Contributor Author

Thank you, @ItsBenCodes !

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.

3 participants