Can't define signal in async component or when using defineRoute
I just tried making the Home function in a default 1.4.1 project into async and also tried using the new defineRoute method, but I got an error:
An error occurred during route handling or page rendering.
Error: Hook can only be invoked from render methods.
at Object.i.__h (https://esm.sh/stable/[email protected]/denonext/debug.js:39:147)
at l (https://esm.sh/stable/[email protected]/denonext/hooks.js:2:168)
at T (https://esm.sh/stable/[email protected]/denonext/hooks.js:2:1458)
at k (https://esm.sh/v113/@preact/[email protected]/X-ZS8q/deno/signals.mjs:2:2274)
at Home (file:///home/echoptic/git/fresh-14/routes/index.tsx:6:17)
at render (https://deno.land/x/[email protected]/src/server/render.ts:216:25)
at https://deno.land/x/[email protected]/src/server/context.ts:790:30
at handler.GET (https://deno.land/x/[email protected]/src/server/context.ts:269:47)
at routes.<computed>.methods.<computed> (https://deno.land/x/[email protected]/src/server/context.ts:857:13)
at handler (https://deno.land/x/[email protected]/src/server/router.ts:197:30)
```
Try using signal() instead of useSignal(). Async routes may look like a component, but aren't actually one. They're just a function that happens to return JSX.
Related https://github.com/denoland/fresh/issues/1540
Try using
signal()instead ofuseSignal(). Async routes may look like a component, but aren't actually one. They're just a function that happens to return JSX.
Props stopped working with this solution
Try using
signal()instead ofuseSignal(). Async routes may look like a component, but aren't actually one. They're just a function that happens to return JSX.Props stopped working with this solution
Can you elaborate on that? I'm having trouble picturing what your code looks like based on that sentence.
Try using
signal()instead ofuseSignal(). Async routes may look like a component, but aren't actually one. They're just a function that happens to return JSX.Props stopped working with this solution
Can you elaborate on that? I'm having trouble picturing what your code looks like based on that sentence.
Just confusion on my end, my mistake
Marking as duplicate of https://github.com/denoland/fresh/issues/1540