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

276
Visualizações
How do you add data to firebase doc using redux thunk getFireBase and getFirestore from react-redux-firebase

Problem

  • I'm having trouble adding data to the firebase database using react-redux-thunk
  • I've checked the documentation and watched multiple youtube videos but keeping running into error after error
  • I want to add data to a firebase doc using the getFirestore and getFirebase middleware from the "redux-firestore" and "react-redux-firebase" library respectively

Code

  • Here is the action function
  • All the code seems to be working but I can't figure out how to add validatonResults to users/uid (see comment in code below)
  • Tried the following code (and a lot of other stuff) but it didn't work firebase.push('users', { data: validatonResults })
import inputValidationAPI from "../../apis/inputValidationAPI"

export const validateTestCase = payload => {
    return (dispatch, getState, { getFirebase, getFirestore }) => {
        const fireStore = getFirestore()
        const firebase = getFirebase()
        const uid = getState().firebase.auth.uid

        inputValidationAPI
            .post("/submitTerm", {
                term: payload
            })
            .then(response => {
                return response.data.data
            })
            .then(validatonResults => {
                /* 
                validationResults = ["string1", "string2", "string3"]
                I want to take validationResults and add them into firebase collection something like:
                
                firebase.push('todos/${uid}', { some: 'data' }) 
                */

                return validatonResults
            })
            .then(validatonResults => {
                dispatch({
                    type: "VALIDATE_TESTCASE_SUCCESS",
                    payload: validatonResults
                })
            })
            .catch(err => console.log(err))
    }
}
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The following syntax solved this:

fireStore.update(
          { collection: "users", doc: uid },
          { dataToSave: someJSONObject },
     }
)
about 4 years ago · Santiago Trujillo 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