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 existing cookie with an empty value is returned as
nullbyuseCookie, because initialization uses a truthiness fallback. Updating a cookie to an empty string works until the component is remounted, when the same persisted value becomesnull.Use a nullish fallback so only a missing cookie maps to
null. Add regression tests for an existing empty cookie and an empty update followed by remount, and document the empty-string/missing-cookie distinction.This addresses value initialization independently of the cookie-name-change behavior proposed in #2723.
Validation
npm testnow passes: 76 suites and 494 tests, using the original Jest configuration.npm run lintpasses with 0 errors and 97 existing warnings after normalizing the local Windows checkout to LF; no source changes were introduced.npm run lint:typesandnpm run build:cjswere attempted. They fail in dependency declarations: initially newer@types/babel__traversesyntax unsupported by TypeScript 4.1.5; using its yarn.lock version (7.11.0) exposes threenano-css/csstypedeclaration errors. No package or lockfile changes are included.git diff --checkpasses.Type of change
Checklist
yarn test)yarn lint).yarn lint:types).ESLint 8 using the repository's configuration passes on both changed TypeScript files (via the isolated dependency harness).