Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to reload page after deleting data from firebase?

After I delete data in the code below, I would like the page to display the change without having to refresh manually. I am sure there are a million ways to do this, but I am looking for best practice. Any tips? (The function below is located in the app component, and I am calling the function using an onClick on a button)

  const deleteBooklet = async (id) => {
    const bookletDoc = doc(db, "Booklet", id);
    await deleteDoc(bookletDoc);
  };

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Use the onSnapshot listener wherever you are reading the data.

This will update as soon as an item is added or deleted. You do not need to reload the page to see the most recent data.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading