You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using React's useId() hook as the id for the anchor element, I'm faced with the following error:
Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '#:r1b:' is not a valid selector.
This is because this component is using document.querySelector(`#${anchorId}`) to access the anchor DOM element, and ids generated by useId() (such as :r1b:) lead to an invalid selector ('#:r1b:').
Version of Package
v5.0.0
To Reproduce
Generate an id with React.useId().
Pass it to anchorId.
The error occurs.
Additional context
Since in v5 the component itself is using the useId(), there's no reason why we shouldn't be able to use for anchor ids as well.
One of the possible solutions is using the document.querySelector(`[id='${anchorId}']`) syntax instead, but I believe there are a few others.
The text was updated successfully, but these errors were encountered:
Describe the bug
When using React's
useId()
hook as the id for the anchor element, I'm faced with the following error:This is because this component is using
document.querySelector(`#${anchorId}`)
to access the anchor DOM element, and ids generated byuseId()
(such as:r1b:
) lead to an invalid selector ('#:r1b:'
).Version of Package
v5.0.0
To Reproduce
React.useId()
.anchorId
.Additional context
Since in v5 the component itself is using the
useId()
, there's no reason why we shouldn't be able to use for anchor ids as well.One of the possible solutions is using the
document.querySelector(`[id='${anchorId}']`)
syntax instead, but I believe there are a few others.The text was updated successfully, but these errors were encountered: