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

70
Views
react-router-dom devuelve indefinido cuando se activa la segunda historia.push

Hola, tengo el siguiente modal Antd:

 <Modal visible={visible} onOk={handleOk} onCancel={handleCancel}> <MyForm onSubmit={handleOpenUrl}> <CustomInput name="input" onChange={(event: React.ChangeEvent<HTMLInputElement>) => handleInput(event, "input") } /> <Button type="submit" > Submit </Button> </MyForm> </Modal>;

Y tengo el siguiente controlador para este formulario:

 const handleInput = (event: React.SyntheticEvent) => { event.preventDefault(); // other operation where checked is handled... history.push({ pathname: "/", search: "?" + new URLSearchParams({ datas: checked }).toString(), }); };

lo extraño es que cuando abro el formulario y envío el formulario por primera vez, actualiza la URL y la agrega de la siguiente manera: http://localhost:3000/?datas=myqueryparams pero cuando lo hago por segunda vez vez que dice: TypeError: Cannot read properties of undefined (reading 'push')

¿Alguna idea sobre eso?

ACTUALIZAR

para el componente de la aplicación, he agregado lo siguiente:

 <Switch> <Route path="/?datas=:datas" exact component={App} /> <Route path="/" exact component={App} /> </Switch>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

¿Ha envuelto el componente de la aplicación con BrowserRouter de react-router-dom? código de ejemplo como este

 import React from "react"; import { BrowserRouter as Router } from "react-router-dom"; export default function App() { return ( <Router> <ChildComponent /> </Router> ); }
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!