Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
How do I update field in my item in realtime database?

I am trying to update one field in my Realtime database node. Currently it is working but I am getting errors after clicking the button even the value in the database changes. Basically changing favorite: true or favorite:false

These are the 2 errors I am receiving when button is pressed.

@firebase/database: FIREBASE WARNING: Exception was thrown by user callback. onValue@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.familyrecipebook&modulesOnly=false&runModule=true:149302:35

TypeError: this.snapshotCallback.call is not a function. (In 'this.snapshotCallback.call(null, expDataSnapshot, previousChildName)', 'this.snapshotCallback.call' is undefined)

This is my current code for updating the value.

const markOrRemoveFavorite = () => {
  const recipeRef = ref(db, 'users/' + userId + '/recepies' + `/${item.id}`)
  // const recipeData = {
  //   favorite: item.favorite ? false : true
  // }

  // const newRecipeKey = push(child(ref(db), 'users/' + userId + '/recepies' + `/${item.id}`)).key

  // const updates = {};
  // updates[newRecipeKey] = recipeData;
  return update(recipeRef, {favorite: item.favorite ? false : true})

}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I solved the issue by following. But text of the button doesnt change still in real time.

    const recipeRef = ref(db, 'users/' + userId + '/recepies' + `/${item.id}`)
     const recipeData = {
       favorite: item.favorite ? false : true
     }

    update(recipeRef, recipeData).then(() => {
      if (item.favorite === false) {
        Toast.show({
          type: 'success',
          position: 'bottom',
          text1: 'Recipe',
          text2: `Recipe ${item.recipe} was added to favorites`,
        })
      } else {
        Toast.show({
          type: 'success',
          position: 'bottom',
          text1: 'Recipe',
          text2: `Recipe ${item.recipe} was removed from favorites`,
        })
      }
    })
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!