Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

247
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda