diff --git a/.changeset/happy-ears-call.md b/.changeset/happy-ears-call.md new file mode 100644 index 000000000000..42171e51b4e5 --- /dev/null +++ b/.changeset/happy-ears-call.md @@ -0,0 +1,5 @@ +--- +'@astrojs/react': patch +--- + +Prevent ID collisions in React.useId diff --git a/packages/astro/test/fixtures/react-component/src/components/WithId.jsx b/packages/astro/test/fixtures/react-component/src/components/WithId.jsx new file mode 100644 index 000000000000..0abe91c72749 --- /dev/null +++ b/packages/astro/test/fixtures/react-component/src/components/WithId.jsx @@ -0,0 +1,6 @@ +import React from 'react'; + +export default function () { + const id = React.useId(); + return
{id}
; +} diff --git a/packages/astro/test/fixtures/react-component/src/pages/index.astro b/packages/astro/test/fixtures/react-component/src/pages/index.astro index abd3d4299055..3afd8233f2d7 100644 --- a/packages/astro/test/fixtures/react-component/src/pages/index.astro +++ b/packages/astro/test/fixtures/react-component/src/pages/index.astro @@ -8,6 +8,7 @@ import Pure from '../components/Pure.jsx'; import TypeScriptComponent from '../components/TypeScriptComponent'; import CloneElement from '../components/CloneElement'; import WithChildren from '../components/WithChildren'; +import WithId from '../components/WithId'; const someProps = { text: 'Hello world!', @@ -34,5 +35,7 @@ const someProps = {