Skip to content

refactor: toggle key generation to use a hash#6

Open
rfdomingues98 wants to merge 1 commit intotoolwind:mainfrom
rfdomingues98:refactor/toggle-key-hash
Open

refactor: toggle key generation to use a hash#6
rfdomingues98 wants to merge 1 commit intotoolwind:mainfrom
rfdomingues98:refactor/toggle-key-hash

Conversation

@rfdomingues98
Copy link
Copy Markdown

@rfdomingues98 rfdomingues98 commented Apr 18, 2026

Fix SSR/hydration mismatch for toggle CSS variables

createToggle previously named its CSS custom property with Math.random(), so the server and client could generate different variable names for the same toggle. That broke hydration when styles depended on those names.

Toggle keys are now derived deterministically from property, on, and off via a small string hash, so the variable name is identical on server and client for the same inputs.

Closes issue #4 .

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.

1 participant