-
Notifications
You must be signed in to change notification settings - Fork 666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
state handling not working using @headlessui/react via preact/compat #2206
Comments
Turns out this does work with a slight change to the import statement https://github.com/hapaxlife/test-fresh-headless-ui/tree/main |
The fix is a bit strange. I got it to work on my end by doing this: {
"imports": {
- "@headlessui/react": "https://esm.sh/@headlessui/react@1.7.17?alias=react:preact/compat,react-dom:preact/compat,@types/react:preact/compat&deps=preact@10.19.2",
+ "@headlessui/react": "https://esm.sh/@headlessui/react@1.7.17?external=react,react-dom&alias=@types/react:preact/compat",
+ "react-dom": "https://esm.sh/preact@10.19.2/compat"
"react": "https://esm.sh/preact@10.19.2/compat",
}
} |
if I change the version of
Seeing As a side note, how do I even debug such errors? I am lost as to where to put the breakpoint or add logging provided this kind of traceback. |
Any progress on this? I'm having the same issues |
See
Currently nothing new. The stacktrace suggests that react-aria is incorrectly determining if it's SRR-ing or not based on window variable, not the document variable. |
I went to close this tab, but figured I'd address this: islands are SSRed, then hydrated. Islands get rendered on both the server and the client. The bug is that react-aria thinks that it's being CSRed while on the server b/c Deno supplies a |
What would I use? That does not work with Deno 2:
|
What error are you getting? |
Here is the code. I did:
https://github.com/perguth/denoland-merch (https://discord.com/channels/684898665143206084/991511118524715139/1296751674442125323) Updates:
"imports": {
"@/": "./",
"$fresh/": "https://deno.land/x/fresh@1.7.2/",
"preact": "https://esm.sh/preact@10.24.3",
"preact/": "https://esm.sh/preact@10.24.3/",
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.2",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.1",
"tailwindcss": "npm:tailwindcss@3.4.1",
"$std/": "https://deno.land/std@0.216.0/",
"swr": "https://esm.sh/v98/swr@1.3.0?alias=react:preact/compat&external=preact/compat",
"@heroicons/react/24/outline": "https://esm.sh/@heroicons/react@2.1.5/24/outline?alias=react:preact/compat,react-dom:preact/compat&external=react,react-dom",
"@headlessui/react": "https://esm.sh/@headlessui/react@2.1.10?alias=react:preact/compat,react-dom:preact/compat&external=react,react-dom",
"@floating-ui/react": "https://esm.sh/@floating-ui/react@latest?alias=react:preact/compat,react-dom:preact/compat&external=react,react-dom",
"@tanstack/react-virtual": "https://esm.sh/@tanstack/react-virtual@latest?alias=react:preact/compat,react-dom:preact/compat&external=react,react-dom",
"@react-aria/interactions": "https://esm.sh/@react-aria/interactions@latest?alias=react:preact/compat,react-dom:preact/compat&external=react,react-dom",
"@react-aria/focus": "https://esm.sh/@react-aria/focus@latest?alias=react:preact/compat,react-dom:preact/compat&external=react,react-dom",
"preact/hooks": "https://esm.sh/preact@10.24.3/hooks",
"react": "https://esm.sh/preact@10.24.3/compat",
"react-dom": "https://esm.sh/preact@10.24.3/compat"
}, |
Did this work for you on Deno Deploy? In my project everything works perfectly fine when running from dev.ts, and also when I build and preview, which is supposed to mimic the prod environment but once I deploy to production I get the same error saying "ReferenceError: document is not defined" even though it builds without issues on Github Actions |
That's a different issue. This is about incorrect versions, while your previous comment, #2426 is about that issue. See my comment over there. |
Thank you for this, it drove me nuts today. I was happy that I finally was able to run headlessui v2 with deno but it seems like some dependencies need to be patched to make it work with deno deploy |
Yeah, it's pretty annoying. I'm still unsure why Deno Deploy doesn't support it. I think it's technically a separate runtime that reuses Deno's crates, and so it's probably not included to avoid breaking existing apps, but I'd sure wish they'd offer an option. Maybe I'll file an issue. |
Was thinking something similar today. Deno build + preview has to mimic a prod environment (deno deploy in this case) afaik. Made me wonder so I found this denoland/deploy_feedback#764, that's the right answer here, they're not even using Deno v2 so I'm guessing that we'll have to wait a little bit more |
Yeah, it's partially chagrining to be because they'd said it was ready, so I almost merged a PR to remove the compat layer. Always test with a production build running on real servers! Also related: denoland/deploy_feedback#666. |
True, thank god it was a personal project and not something critical, next time I'll trust but verify |
I'm trying to use preact/compat to leverage @headlessui/react, but running into
In the "imports" of my deno.json I have
The input renders, and fires the callback, but something about the useState seems off as I see some minified property is not a function, as in the attached image.
Here is my implementation of the component within this repository featuring a minimal reproduction of the issue.
Thanks in advance!
The text was updated successfully, but these errors were encountered: