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

151
Visualizações
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 à 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