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

112
Vistas
How do I prevent react from reloading page when form is submitted

I can't figure out why event.preventDefault() isn't working in my chargeCardNow function.

The page is refreshing when the button in the form is clicked. Am I missing something obvious?

  chargeCardNow = (event, tickets) => {
    event.preventDefault();
    if (this.props.purchaseErrorsExist(tickets)) {return}  
    this.props.clearMessage()
    this.toggleDisablePurchaseButton()
    let message = "Checking for tickets. Please Wait..."
    this.props.updateMessage(message)
    this.getClientSecret() 
  };

      <form>

        <input type="email" placeholder="Email Address" 
          required
          value={this.props.purchaserEmail}
          disabled = {this.isUserLoggedIn()}
          onChange={event => this.props.changeEmail(event)}
          className={'match-stripe'}
        />

        <CardElement/>

        <button onSubmit={(e) => this.chargeCardNow(e, this.props.tickets)}>
            {`Purchase Tickets`}
        </button>
  
     </form>
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