Preact hooks doesn't get executed!
im having a little problem, the hooks from preact doesn't seem to run, canst see any errors in the terminal and the dependency is imported. Would love to get help:)
import { useEffect } from "preact/hooks";
export default function MyPage() {
useEffect(()=> {
console.log("this message will not be executed:(")
}, []);
return (
blah blah blah
)
}
14 Replies
I recommend checking out the docs: https://fresh.deno.dev/docs/concepts/islands
Interactive islands | Fresh docs
Islands enable client side interactivity in Fresh. They are hydrated on the client in addition to being rendered on the server.
All interaction must happen within islands
What lino said. Fresh is a server first framework and it expects you to opt into client side code via islands
@lino-levan @marvinh. Thank you! I'm looking into it! Would you be against a DM if I have further questions?
Feel free to post in this thread! It's better for searchability in case others get stuck on the same problem.
im trying to display a invoice and i log the data when fetching it from my supabase(as seen in the blue console screenshot). When the invoices are loaded i try to display it in the table but nothing is there. i have a button for dubug purposes that logs listOfInvoices.value to the console and when i do that it is displaying a empty array.
How can it be that listOfInvoices has data when fetched but later when used inside of the html it's empty?
I think i understand the problem, when fetching this error gets thrown into the browser console!
here is the invoicesUtils.ts
so the problem has to do with retrieving the supabase url and key
you cant use
Deno.*
there. Either a call to an api in the routes/api/
folder, or a handler in that routeCreating a CRUD API | Fresh docs
Use HTTP CRUD methods to perform operations on resources. Learn how to use HTTP handlers to create a RESTful API.
Routes | Fresh docs
Routes are the basic building block of Fresh applications. They are used to define the behaviour the application when a given path is requested.
Ahhh! I will need some time to understand it properly! Thank you!
youre welcome!