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

153
Vistas
Pass multiple arguments to function in React JS

I want to pass multiple arguments to a function in React js.

I try making it like this:

 const uwu = async(e, id) => {         // <-- Here is the multiple arguments the e and id.
    e.preventDefault()
    
    try {
      const docRef = collection(db, "proyects", id, "tasks");
    
    await addDoc(docRef, {
      taskName: taskName,
      uid: currentUser,
      projectId: id
    })
    console.log("QUE PEDO?")
    } catch (error) {
      console.log(error)
    }
    
    
  }

But then the console throws me this error:

enter image description here

I am calling the "uwu" function, with a onSubmit on a form inside a map() that renders the data that i have in firebase. Like this:

{
        loading ?
        data.map(doc => (
          <div key={doc.id}>
              <h2 key={doc.id}>{doc.id}</h2>
              <form onSubmit={() => uwu(doc.id)}>  // <------
                <input
                placeholder="añadir tareuvich"
                onChange={e => setTaskName(e.target.value)}
                />
                <button>Crear</button>
              </form>
              {
                tasksData.map(task => (
                  
                  <div key={task.id}>
                    { task.projectId == doc.projectId && <h5>{task.taskName}</h5>}
                  </div>
                   
                  
                ))
              }
          </div>
        )) : 'Loading...'
      }

Aparrently the e.preventDefault() is not working as usual, but then if i remove the e.preventDefault and also the (e) from the arguments and just leave the "id" it works... any solution?

about 4 years ago · Juan Pablo Isaza
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