-
Notifications
You must be signed in to change notification settings - Fork 647
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
Error: Hook can only be invoked from render methods #1540
Comments
A very minimal reproduction is: import { useSignal } from "@preact/signals";
export default async function Home() {
const sliderSignal = useSignal(50);
return "hi";
} This works fine: import { useSignal } from "@preact/signals";
export default function Home() {
const sliderSignal = useSignal(50);
return "hi";
} |
Yup, under the hood async route components aren't really components but rather a function that happens to return JSX. Because of the missing component instance hooks don't work. Support for proper async components is currently in the works, but needs a bit more time to cook. |
@marvinhagemeister any update on if this is a roadmap? |
This comment was marked as outdated.
This comment was marked as outdated.
We .. err might walk back on that one. Async components are supported in Preact, but not with hooks and it turns out it's a hell to do so without a custom transpile pass. So we're likely not shipping that in Fresh 2. Been meaning to write an update on the current state of things in the Fresh 2 roadmap thread. |
If merging handler and render with a async render using hook, error throwed
here's the example in Multiple Sibling Islands with Shared State
https://fresh.deno.dev/docs/examples/sharing-state-between-islands
Error: Hook can only be invoked from render methods
[UPDATE] In this case, using Independent Islands example should be the proper way (error comes from that the handler part run on the server)
The text was updated successfully, but these errors were encountered: