wedmaniac
wedmaniac14mo ago

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
ioB
ioB14mo ago
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.
ioB
ioB14mo ago
All interaction must happen within islands
marvinh.
marvinh.14mo ago
What lino said. Fresh is a server first framework and it expects you to opt into client side code via islands
wedmaniac
wedmaniacOP14mo ago
@lino-levan @marvinh. Thank you! I'm looking into it! Would you be against a DM if I have further questions?
ioB
ioB14mo ago
Feel free to post in this thread! It's better for searchability in case others get stuck on the same problem.
wedmaniac
wedmaniacOP14mo ago
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.
No description
No description
No description
No description
wedmaniac
wedmaniacOP14mo ago
How can it be that listOfInvoices has data when fetched but later when used inside of the html it's empty?
wedmaniac
wedmaniacOP14mo ago
I think i understand the problem, when fetching this error gets thrown into the browser console!
No description
wedmaniac
wedmaniacOP14mo ago
here is the invoicesUtils.ts
No description
wedmaniac
wedmaniacOP14mo ago
so the problem has to do with retrieving the supabase url and key
javi
javi14mo ago
you cant use Deno.* there. Either a call to an api in the routes/api/ folder, or a handler in that route
javi
javi14mo ago
this and this for reference
Creating 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.
wedmaniac
wedmaniacOP14mo ago
Ahhh! I will need some time to understand it properly! Thank you!
javi
javi14mo ago
youre welcome!