How to use remove() (Firebase SDK 9 web)

Viewed 124

How to use "remove()" in SDK v9 web?

(context: I'm learning React Native (using Expo) and there's this todo app).

There are no examples in the documentation. Here is what I have:

    // firebase
import app from "./firebaseConfig";
 
import {
  getDatabase,
  ref,
  set,
  push,
  onValue,
  remove,
  child,
} from "firebase/database";
 
// etc
 
const db = getDatabase(app);
const taskListRef = ref(db, "tarefas/" + user);
const newTaskRef = push(taskListRef);
 
// etc
 
const handleDelete = (key) => {
    remove(taskListRef).then(() => {
      const findTasks = tasks.filter((item) => item.key !== key);
      setTasks(findTasks);
    });
  };

So, this remove(taskListRef) is my problem. I don't know how to call it properly regarding the reference to the data location.

I've tried: remove(taskListRef.child(user)), remove(taskListRef.child(key)) etc... and a bunch of other similar things. The error always: wrong reference.

Here is the repo. Please, help. Thank you all in advance.

P.S.: hopefully I won't have to ask a similar question regarding update().

0 Answers
Related