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

208
Views
how to save user form input data to firestore in reactnative

i've been trying to submit user input to my firebase database but it doesn't work for me. i'm a beginner in react-native and firebase. i have 3 input fields and want to save the data entered by user into my database after clicking on submit.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Let's say you have those inputs ready, let's say you have them stored in i don't know states maybe. Then if we talk about firestore you would do something like this :

const onSubmit = () => {

firestore() 
.collection('your collection') 
.doc(auth().currentUser.uid)
.set({
name : state.name, 
email : state.email
// and so on 
}) 
.then(() => {
// do something like logging 'user registered' 
}) 
} 

Note that the comments you received earlier are rights. This is just an example of what you can do, guessing this is what you were asking. But your question need to be more precise in the future so you can get better support

Also check the firebase or react-native-firebase documentations depending on which one you are using because the way of doing things might be a bit different. The one i showed you is with the react-native-firebase library

about 4 years ago · Juan Pablo Isaza Report

0

Let's say you have some data in the state from the text input:

const [dataState,setDataState] = useState("Some data from text Input")

Now let's say you want to upload it to firebasee. First you need to have the firebase app initialized. Often you do this in a separate file. Here's how:

import  {initializeApp} from 'firebase/app'
import {firestore} from 'firebase/firestore'

const firebaseConfig = {
    ..your keys 
}

initializeApp(firebaseConfig)
const db = firestore()

export db;

Now that you have your app initialized, go to your main file/screen (like app.js):

import {db} from './yourFirebaseFile'
import  {collection,addDoc} from 'firebase/firestore'

Now let's say you have the data in your state from the text input. Let's create a function to send the data to firebase (you can all this function on press of a button)

const sendToFirestore = async() => {
      await addDoc( collection(db, "Your_Collections_Name_in_firebase"), {
               dataFromInput : dataState
  } )}

There you go! You have the data saved (:

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!