Repository navigation
fix(useCookie): preserve empty cookie values - #2727
Open
feritcemkahraman wants to merge 1 commit into
Open
feritcemkahraman wants to merge 1 commit into
feritcemkahraman wants to merge 1 commit into
Conversation
feritcemkahraman
marked this pull request as ready for review
October 8, 2026 01:46
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
An empty cookie becomes
nullwhen the component remounts, even thoughuseCookieaccepts''when setting it. Use a nullish fallback so an empty cookie stays empty and only a missing cookie becomesnull.The tests cover reading an existing empty cookie and setting one before remounting. The docs now explain that distinction. Cookie-name changes are handled separately in #2723.
Checked with the original Jest setup: 494 tests in 76 suites pass, including all six cookie tests. Full lint passes with 97 existing warnings. The changed hook passes a strict TypeScript check; full type/build checks still fail in the existing nano-css/csstype dependency declarations.
Validation details
Both new tests fail before the fix. Hook coverage is 100% statements/functions/lines and 90.9% branches, including transpiler branches. Jest 26, React 17.0.2 and js-cookie 3.0.5 were used. The full lint run used an LF-normalized local Windows checkout.
The original yarn.lock Babel types were used to get past newer syntax unsupported by TypeScript 4.1.5; three nano-css/csstype declaration errors remain. No package or lockfile changes are included.
git diff --checkpasses. Storybook was not built.Type of change
Checklist
yarn test)yarn lint).yarn lint:types).