Skip to content

uniqueId() causes hydration warnings with server-side rendering #1392

Closed
@jclem

Description

@jclem

Describe the bug

When using server-side rendering, the uniqueId() function causes hydration warnings because the idSeed counter is globally shared for all renders for all users while it's reset to 10,000 on the client.

Additionally, this has the unintended side effect of leaking information about how many times a given page is visited (per rendering process, at least).

To Reproduce

Render any Primer component that uses uniqueId() using server-side rendering.

Expected behavior

The same ID is used on the server as on the client.

Screenshots

CleanShot 2021-08-24 at 13 10 38@2x

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions