Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

209
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda