Astro Info
Astro v7.2.1
Node v22.21.1
System macOS (arm64)
Package Manager bun
Output static
Adapter @astrojs/cloudflare
Integrations @astrojs/react
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
This is a follow-up to #16529, which was closed with "We believe this is likely fixed in Astro 7." The error is still present on Astro 7.2.1.
Repro:
- bun install (or npm install)
- rm -rf node_modules/.vite
- bunx astro dev
- Request the page one time: curl -s http://localhost:4321/ | wc -c
- Request the page a second time.
The first response is 420 bytes and holds no astro-island element. The server logs:
[ERROR] [vite] Invalid hook call. Hooks can only be called inside of the body of a function component.
[ERROR] [vite] TypeError: Cannot read properties of null (reading 'useState')
at Object.exports.useState (node_modules/react/cjs/react.development.js:1263:33)
at ReproCounter (src/components/ReproCounter.tsx:4:29)
at renderWithHooks (node_modules/.vite/deps_ssr/react-dom_server.js:2797:19)
This is caused by using React and the Cloudflare adapter. The docs do not mention any caveats when using both.
What's the expected result?
The first response renders the island.
Link to Minimal Reproducible Example
https://github.com/valkum/astro-7-react-cloudflare-issue
Participation
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
This is a follow-up to #16529, which was closed with "We believe this is likely fixed in Astro 7." The error is still present on Astro 7.2.1.
Repro:
The first response is 420 bytes and holds no astro-island element. The server logs:
This is caused by using React and the Cloudflare adapter. The docs do not mention any caveats when using both.
What's the expected result?
The first response renders the island.
Link to Minimal Reproducible Example
https://github.com/valkum/astro-7-react-cloudflare-issue
Participation