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

273
Views
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 answers
Answer question

0

The following syntax solved this:

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