When calling the callFunc outside of this subscription context everything works fine and all my items are logged. However when I add a new Task callFunc will get called but the logged state is the empty state of of starting my application. How can this be?
const receivedEvent = (payload: any) => {
console.log(payload);
callFunc();
};
const callFunc = () => {
console.log(items);
};
useEffect(() => {
const subscription = supabase
.channel("Task")
.on(
"postgres_changes",
{ event: "INSERT", schema: "public", table: "Task" },
receivedEvent
)
.subscribe();
return () => {
subscription.unsubscribe();
};
}, []);