diff --git a/.changeset/thin-plums-drop.md b/.changeset/thin-plums-drop.md new file mode 100644 index 0000000000..ab3fb875aa --- /dev/null +++ b/.changeset/thin-plums-drop.md @@ -0,0 +1,5 @@ +--- +'@astrojs/react': patch +--- + +fix a bug where react identifierPrefix was set to null for client:only components causing React.useId to generate ids prefixed with null diff --git a/packages/astro/e2e/fixtures/react-component/src/components/WithId.jsx b/packages/astro/e2e/fixtures/react-component/src/components/WithId.jsx new file mode 100644 index 0000000000..0abe91c727 --- /dev/null +++ b/packages/astro/e2e/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/e2e/fixtures/react-component/src/pages/index.astro b/packages/astro/e2e/fixtures/react-component/src/pages/index.astro index f9e0ae3958..a3a0a4c1f0 100644 --- a/packages/astro/e2e/fixtures/react-component/src/pages/index.astro +++ b/packages/astro/e2e/fixtures/react-component/src/pages/index.astro @@ -2,6 +2,7 @@ import Counter from '../components/Counter.jsx'; import ReactComponent from '../components/JSXComponent.jsx'; import Suffix from '../components/Suffix.react'; +import WithId from '../components/WithId.jsx'; const someProps = { count: 0, @@ -36,5 +37,11 @@ const someProps = {