DEV Community

Discussion on: Build a Full-Stack Notebook App using React and Firebase 📓 🔥

Collapse
 
ankitdevelops profile image
Ankit Kumar

Hey can you please explain what this line of code is doing.

firebase
.database()
.ref("notebook")
.on("child_removed", (snapshot) => {
let notebook = noteBookData;
notebook = noteBookData.filter((note) => note.id !== snapshot.key);
setNoteBookData(notebook);
});
};

Collapse
 
pramit_marattha profile image
Pramit Marattha • Edited

Yeap sure !!
firebase.database().ref() simply reference a specific location in your database that can be used for reading and writing data to that particular Database location and also you can use "on()" and "once()" either of these methods to read data at a path and listen for any changes ....and after that, we are simply passing the callback which filters the value and sends / updates to our main state.