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

135
Views
Cómo usar event.preventDefault() cuando la función tiene argumentos

tengo un código como este:

 const upListCandy = (candy) => { /* How i add event.preventDefault() and it word*/ axios.post("example.com", { candyName: candy.name }).then().catch() }

aquí está mi botón:

 dataCandy?.map((item, index) => { return( <div key={index}> <button onClick = {() => upListCandy(item)}>{item.name}</button> </div> ) })

Y mi pregunta es ¿cómo funciona agregar el parámetro de evento y luego event.preventDefault()?

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

0

modifica tu onclick así

 <button onClick = {(e) => upListCandy(item,e)}>{item.name}</button>

y entonces

 const upListCandy = (candy,event) => { event.preventDefault(); axios.post("example.com", { candyName: candy.name }).then().catch() }
about 4 years ago · Juan Pablo Isaza Report

0

Creo que puedes cambiarlo así.

 dataCandy?.map((item, index) => { return( <div key={index}> <button onClick = {(e) => upListCandy(e,item)}>{item.name}</button> </div> ) })
 const upListCandy = (e,ceandy) => { e.preventDefault() axios.post("example.com", { candyName: candy.name }).then().catch() }
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!