Firebase Real events
Unanswered
Black Caiman posted this in #help-forum
Black CaimanOP
Hi guys, Currenlty i am trying to explore firebase realtime database after read the docs i found this two method onValue onChildAdded my issue with them that they retrieve old data on load which lead to activate my callback funtction and i dont need that behvior as i have my own backend i just want the new children
this is the skeleton of my hook
this is the skeleton of my hook
export default function useFirebase(callback: (data: unknown) => void) {
const isInit = useRef(false);
useEffect(() => {
const eventsRef = ref(db, 'events/class_started');
const unsubscribe = onChildAdded(eventsRef, (data) => {
const eventData = data.val();
callback(data)
});
return () => {
unsubscribe();
}
})
}