GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add : to beginning and end of every useId by acdlite · Pull Request #23360 · react/react

Conversation

@acdlite

@acdlite acdlite commented Feb 25, 2022

Copy link
Copy Markdown
Collaborator

The ids generated by useId are unique per React root. You can create additional ids by concatenating them with locally unique strings.

To support this pattern, no id will ever be a subset of another id. We achieve this by adding a special character to the beginning and end.

We use a colon (":") because it's uncommon — even if you don't prefix the ids using the identifierPrefix option, collisions are unlikely.

One downside of a colon is that it's not a valid character in DOM selectors, like querySelectorAll. We think this is probably
fine because it's not a common use case in React, and there are workarounds or alternative solutions. But we're open to reconsidering this in the future if there's a compelling argument.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sizebot

sizebot commented Feb 25, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Comparing: 42f15b3...030815d

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js +0.01% 131.33 kB 131.35 kB +0.03% 42.01 kB 42.02 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js +0.01% 136.16 kB 136.17 kB +0.02% 43.43 kB 43.44 kB
facebook-www/ReactDOM-prod.classic.js +0.02% 434.37 kB 434.44 kB +0.02% 79.43 kB 79.45 kB
facebook-www/ReactDOM-prod.modern.js +0.02% 424.16 kB 424.23 kB +0.02% 77.99 kB 78.01 kB
facebook-www/ReactDOMForked-prod.classic.js +0.02% 434.37 kB 434.44 kB +0.02% 79.43 kB 79.45 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 030815d

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@acdlite
Add : to beginning and end of every useId
030815d
The ids generated by useId are unique per React root. You can create
additional ids by concatenating them with locally unique strings.

To support this pattern, no id will ever be a subset of another id. We
achieve this by adding a special character to the beginning and end.

We use a colon (":") because it's uncommon — even if you don't prefix
the ids using the `identifierPrefix` option, collisions are unlikely.

One downside of a colon is that it's not a valid character in DOM
selectors, like `querySelectorAll`. We think this is probably
fine because it's not a common use case in React, and there are
workarounds or alternative solutions. But we're open to reconsidering
this in the future if there's a compelling argument.
@acdlite
acdlite force-pushed the id-colon branch from 2318366 to 030815d Compare February 25, 2022 00:48
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Feb 25, 2022
@acdlite
acdlite requested a review from sebmarkbage February 25, 2022 00:53
rickhanlonii
rickhanlonii approved these changes Feb 25, 2022
View reviewed changes
@acdlite
acdlite merged commit efe4121 into react:main Feb 25, 2022
facebook-github-bot pushed a commit to react/react-native that referenced this pull request Mar 1, 2022
@kacieb @facebook-github-bot
React Native sync for revisions 4de99b3...1780659
6a4e905
Summary:
This sync includes the following changes:
- **[1780659](react/react@17806594c )**: Move createRoot/hydrateRoot to react-dom/client ([#23385](react/react#23385)) //<Sebastian Markbåge>//
- **[75662d6](react/react@75662d6a7 )**: Remove hacky stream.locked check, declare as byte stream instead ([#23387](react/react#23387)) //<Sebastian Markbåge>//
- **[a82ef6d](react/react@a82ef6d40 )**: Add back skipUnmountedBoundaries flag only for www ([#23383](react/react#23383)) //<Andrew Clark>//
- **[f468816](react/react@f468816ef )**: Fix false positive hydration warnings ([#23364](react/react#23364)) //<Andrew Clark>//
- **[5d08a24](react/react@5d08a24c2 )**: useId: Use 'H' to separate main id from hook index ([#23363](react/react#23363)) //<Andrew Clark>//
- **[3a60844](react/react@3a60844a0 )**: Update error message for suspending at sync priority ([#23361](react/react#23361)) //<Andrew Clark>//
- **[efe4121](react/react@efe4121ee )**: Add : to beginning and end of every useId ([#23360](react/react#23360)) //<Andrew Clark>//
- **[42f15b3](react/react@42f15b324 )**: [DevTools][Transition Tracing] onTransitionComplete and onTransitionStart implmentation ([#23313](react/react#23313)) //<Luna Ruan>//
- **[a5b2215](react/react@a5b22155c )**: Warn if renderSubtreeIntoContainer is called ([#23355](react/react#23355)) //<Andrew Clark>//
- **[52c393b](react/react@52c393b5d )**: Revert to client render on text mismatch ([#23354](react/react#23354)) //<Andrew Clark>//
- **[1ad8d81](react/react@1ad8d8129 )**: Remove object-assign polyfill ([#23351](react/react#23351)) //<Sebastian Markbåge>//
- **[b3f3da2](react/react@b3f3da205 )**: Land warnOnSubscriptionInsideStartTransition flag ([#23353](react/react#23353)) //<Andrew Clark>//
- **[990098f](react/react@990098f88 )**: Re-arrange main ReactFeatureFlags module ([#23350](react/react#23350)) //<Andrew Clark>//
- **[1f3f6db](react/react@1f3f6db73 )**: Remove createMutableSource from stable exports ([#23352](react/react#23352)) //<Andrew Clark>//
- **[587e759](react/react@587e75930 )**: Remove Numeric Fallback of Symbols ([#23348](react/react#23348)) //<Sebastian Markbåge>//
- **[4035157](react/react@40351575d )**: Split writeChunk into void and return value ([#23343](react/react#23343)) //<Sebastian Markbåge>//
- **[2c693b2](react/react@2c693b2de )**: Re-add reentrancy avoidance ([#23342](react/react#23342)) //<Sebastian Markbåge>//
- **[1760b27](react/react@1760b27c0 )**: Remove ./src/* export from public build ([#23262](react/react#23262)) //<Andrew Clark>//
- **[552c067](react/react@552c067bb )**: Remove public export for unstable-shared-subset.js ([#23261](react/react#23261)) //<Andrew Clark>//

Changelog:
[General][Changed] - React Native sync for revisions 4de99b3...1780659

jest_e2e[run_all_tests]

Reviewed By: rickhanlonii

Differential Revision: D34552175

fbshipit-source-id: f1c831a45f96d335a20c3b4113196e0a42cefc03
@rickhanlonii rickhanlonii mentioned this pull request Mar 23, 2022
RFC: Intent to ship React 18 reactjs/rfcs#212
Merged
zhengjitf pushed a commit to zhengjitf/react that referenced this pull request Apr 15, 2022
@acdlite @zhengjitf
Add : to beginning and end of every useId (react#23360)
278249d
The ids generated by useId are unique per React root. You can create
additional ids by concatenating them with locally unique strings.

To support this pattern, no id will ever be a subset of another id. We
achieve this by adding a special character to the beginning and end.

We use a colon (":") because it's uncommon — even if you don't prefix
the ids using the `identifierPrefix` option, collisions are unlikely.

One downside of a colon is that it's not a valid character in DOM
selectors, like `querySelectorAll`. We think this is probably
fine because it's not a common use case in React, and there are
workarounds or alternative solutions. But we're open to reconsidering
this in the future if there's a compelling argument.
Saadnajmi pushed a commit to Saadnajmi/react-native-macos that referenced this pull request Jan 15, 2023
@kacieb @Saadnajmi
React Native sync for revisions 4de99b3...1780659
cde01ad
Summary:
This sync includes the following changes:
- **[1780659](react/react@17806594c )**: Move createRoot/hydrateRoot to react-dom/client ([react#23385](react/react#23385)) //<Sebastian Markbåge>//
- **[75662d6](react/react@75662d6a7 )**: Remove hacky stream.locked check, declare as byte stream instead ([react#23387](react/react#23387)) //<Sebastian Markbåge>//
- **[a82ef6d](react/react@a82ef6d40 )**: Add back skipUnmountedBoundaries flag only for www ([react#23383](react/react#23383)) //<Andrew Clark>//
- **[f468816](react/react@f468816ef )**: Fix false positive hydration warnings ([react#23364](react/react#23364)) //<Andrew Clark>//
- **[5d08a24](react/react@5d08a24c2 )**: useId: Use 'H' to separate main id from hook index ([react#23363](react/react#23363)) //<Andrew Clark>//
- **[3a60844](react/react@3a60844a0 )**: Update error message for suspending at sync priority ([react#23361](react/react#23361)) //<Andrew Clark>//
- **[efe4121](react/react@efe4121ee )**: Add : to beginning and end of every useId ([react#23360](react/react#23360)) //<Andrew Clark>//
- **[42f15b3](react/react@42f15b324 )**: [DevTools][Transition Tracing] onTransitionComplete and onTransitionStart implmentation ([react#23313](react/react#23313)) //<Luna Ruan>//
- **[a5b2215](react/react@a5b22155c )**: Warn if renderSubtreeIntoContainer is called ([react#23355](react/react#23355)) //<Andrew Clark>//
- **[52c393b](react/react@52c393b5d )**: Revert to client render on text mismatch ([react#23354](react/react#23354)) //<Andrew Clark>//
- **[1ad8d81](react/react@1ad8d8129 )**: Remove object-assign polyfill ([react#23351](react/react#23351)) //<Sebastian Markbåge>//
- **[b3f3da2](react/react@b3f3da205 )**: Land warnOnSubscriptionInsideStartTransition flag ([react#23353](react/react#23353)) //<Andrew Clark>//
- **[990098f](react/react@990098f88 )**: Re-arrange main ReactFeatureFlags module ([react#23350](react/react#23350)) //<Andrew Clark>//
- **[1f3f6db](react/react@1f3f6db73 )**: Remove createMutableSource from stable exports ([react#23352](react/react#23352)) //<Andrew Clark>//
- **[587e759](react/react@587e75930 )**: Remove Numeric Fallback of Symbols ([react#23348](react/react#23348)) //<Sebastian Markbåge>//
- **[4035157](react/react@40351575d )**: Split writeChunk into void and return value ([react#23343](react/react#23343)) //<Sebastian Markbåge>//
- **[2c693b2](react/react@2c693b2de )**: Re-add reentrancy avoidance ([react#23342](react/react#23342)) //<Sebastian Markbåge>//
- **[1760b27](react/react@1760b27c0 )**: Remove ./src/* export from public build ([react#23262](react/react#23262)) //<Andrew Clark>//
- **[552c067](react/react@552c067bb )**: Remove public export for unstable-shared-subset.js ([react#23261](react/react#23261)) //<Andrew Clark>//

Changelog:
[General][Changed] - React Native sync for revisions 4de99b3...1780659

jest_e2e[run_all_tests]

Reviewed By: rickhanlonii

Differential Revision: D34552175

fbshipit-source-id: f1c831a45f96d335a20c3b4113196e0a42cefc03
@sebmarkbage sebmarkbage mentioned this pull request Jan 7, 2025
Use valid CSS selectors in useId format #32001
Merged
sebmarkbage added a commit that referenced this pull request Feb 25, 2025
@sebmarkbage
Use valid CSS selectors in useId format (#32001)
2e4db33
For the `useId` algorithm we used colon `:` before and after.
#23360

This avoids collisions in general by using an unusual characters. It
also avoids collisions when concatenated with some other ID.
Unfortunately, `:` is not a valid character in `view-transition-name`.

This PR swaps the format from:

```
:r123:
```

To the unicode:

```
«r123»
```

Which is valid CSS selectors. This also allows them being used for
`querySelector()` which we didn't really find a legit use for but seems
ok-ish.

That way you can get a view-transition-name that you can manually
reference. E.g. to generate styles:

```js
const id = useId();
return <>
  <style>{`
    ::view-transition-group(${id}) { ... }
    ::view-transition-old(${id}) { ... }
    ::view-transition-new(${id}) { ... }
  `}</style>
  <ViewTransition name={id}>...</ViewTransition>
</>;
```
github-actions Bot pushed a commit that referenced this pull request Feb 25, 2025
@sebmarkbage
Use valid CSS selectors in useId format (#32001)
bcae4ac
For the `useId` algorithm we used colon `:` before and after.
#23360

This avoids collisions in general by using an unusual characters. It
also avoids collisions when concatenated with some other ID.
Unfortunately, `:` is not a valid character in `view-transition-name`.

This PR swaps the format from:

```
:r123:
```

To the unicode:

```
«r123»
```

Which is valid CSS selectors. This also allows them being used for
`querySelector()` which we didn't really find a legit use for but seems
ok-ish.

That way you can get a view-transition-name that you can manually
reference. E.g. to generate styles:

```js
const id = useId();
return <>
  <style>{`
    ::view-transition-group(${id}) { ... }
    ::view-transition-old(${id}) { ... }
    ::view-transition-new(${id}) { ... }
  `}</style>
  <ViewTransition name={id}>...</ViewTransition>
</>;
```

DiffTrain build for [2e4db33](2e4db33)
github-actions Bot pushed a commit that referenced this pull request Feb 25, 2025
@sebmarkbage
Use valid CSS selectors in useId format (#32001)
5849887
For the `useId` algorithm we used colon `:` before and after.
#23360

This avoids collisions in general by using an unusual characters. It
also avoids collisions when concatenated with some other ID.
Unfortunately, `:` is not a valid character in `view-transition-name`.

This PR swaps the format from:

```
:r123:
```

To the unicode:

```
«r123»
```

Which is valid CSS selectors. This also allows them being used for
`querySelector()` which we didn't really find a legit use for but seems
ok-ish.

That way you can get a view-transition-name that you can manually
reference. E.g. to generate styles:

```js
const id = useId();
return <>
  <style>{`
    ::view-transition-group(${id}) { ... }
    ::view-transition-old(${id}) { ... }
    ::view-transition-new(${id}) { ... }
  `}</style>
  <ViewTransition name={id}>...</ViewTransition>
</>;
```

DiffTrain build for [2e4db33](2e4db33)
@coderabbitai coderabbitai Bot mentioned this pull request Apr 17, 2026
✨ feat(player): phase 7.5 — compound slots + playListExpanded + multi-playList slash9494/react-modern-audio-player#56
Merged
5 tasks done
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
@acdlite
Add : to beginning and end of every useId (react#23360)
ecd6060
The ids generated by useId are unique per React root. You can create
additional ids by concatenating them with locally unique strings.

To support this pattern, no id will ever be a subset of another id. We
achieve this by adding a special character to the beginning and end.

We use a colon (":") because it's uncommon — even if you don't prefix
the ids using the `identifierPrefix` option, collisions are unlikely.

One downside of a colon is that it's not a valid character in DOM
selectors, like `querySelectorAll`. We think this is probably
fine because it's not a common use case in React, and there are
workarounds or alternative solutions. But we're open to reconsidering
this in the future if there's a compelling argument.
@coderabbitai coderabbitai Bot mentioned this pull request Jul 12, 2026
feat(web): sculpted 3D BodyAtlas rendering (design variant 2а) SkOrDs-02/sergeant#270
Merged
13 of 15 tasks
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@acdlite
Add : to beginning and end of every useId (react#23360)
e9cae7c
The ids generated by useId are unique per React root. You can create
additional ids by concatenating them with locally unique strings.

To support this pattern, no id will ever be a subset of another id. We
achieve this by adding a special character to the beginning and end.

We use a colon (":") because it's uncommon — even if you don't prefix
the ids using the `identifierPrefix` option, collisions are unlikely.

One downside of a colon is that it's not a valid character in DOM
selectors, like `querySelectorAll`. We think this is probably
fine because it's not a common use case in React, and there are
workarounds or alternative solutions. But we're open to reconsidering
this in the future if there's a compelling argument.
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@sebmarkbage
Use valid CSS selectors in useId format (react#32001)
0a9315f
For the `useId` algorithm we used colon `:` before and after.
react#23360

This avoids collisions in general by using an unusual characters. It
also avoids collisions when concatenated with some other ID.
Unfortunately, `:` is not a valid character in `view-transition-name`.

This PR swaps the format from:

```
:r123:
```

To the unicode:

```
«r123»
```

Which is valid CSS selectors. This also allows them being used for
`querySelector()` which we didn't really find a legit use for but seems
ok-ish.

That way you can get a view-transition-name that you can manually
reference. E.g. to generate styles:

```js
const id = useId();
return <>
  <style>{`
    ::view-transition-group(${id}) { ... }
    ::view-transition-old(${id}) { ... }
    ::view-transition-new(${id}) { ... }
  `}</style>
  <ViewTransition name={id}>...</ViewTransition>
</>;
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sebmarkbage sebmarkbage Awaiting requested review from sebmarkbage
1 more reviewer
@rickhanlonii rickhanlonii rickhanlonii approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@acdlite @sizebot @rickhanlonii @facebook-github-bot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.