-
Notifications
You must be signed in to change notification settings - Fork 49.5k
Closed
Closed
Copy link
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug
Description
The ID scheme for the useId
hook returns IDs that look like ":S1:"
, but :
is not a valid character for CSS identifiers and must be escaped. On client-only components, you can wrap the ID in CSS.escape
but the CSS
global object doesn't exist on the server so this doesn't work for server-component renders.
React version: 18.2
Steps To Reproduce
- Try utilizing the id's created by
useId
in CSS identifiers. - It doesn't work.
Link to code example: https://stackblitz.com/edit/react-ts-zhtk6u?file=Example.tsx
The current behavior
The current implementation of useId
creates IDs with special characters which can conflict with certain DSLs (in this example, CSS) that React has to commonly interact with.
The expected behavior
Don't use special characters in IDs created by useId
.
Dattaya, danieldevlewis, joekur, greypants, Denis-Andreev and 18 more
Metadata
Metadata
Assignees
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug