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

234
Views
¿Cómo paso un estado en un elemento de ruta en el enrutador de reacción?
... import { useNavigate, NavigateFunction } from "react-router"; ... function Form(): JSX.Element { const navigate: NavigateFunction = useNavigate(); const [country, setCountry] = useState<string>(" "); const handleChange = (e: ChangeEvent<HTMLInputElement>): void => { setCountry(e.target.value); }; const handleSubmit = (e: FormEvent<HTMLFormElement>): void => { e.preventDefault(); navigate("/country"); }; return ( <Box component="form" onSubmit={handleSubmit}> <input type={"text"} required placeholder="Enter Country" value={country} onChange={handleChange} ></input> <Button variant={"contained"} type="submit"> Search </Button> </Box> ); } export default Form;

este es mi archivo index.tsx:

 ReactDOM.render( <React.StrictMode> <BrowserRouter> <Routes> <Route path="/" element={<App />} /> <Route path="/country" element={<CountryDetails />} /> </Routes> </BrowserRouter> </React.StrictMode>, document.getElementById("root") );

este es mi archivo CountryDetails.tsx:

 const CountryDetails = (): JSX.Element => { const country: string | undefined = useParams().name; return ( <Box> hi ${country} </Box> ) } export default CountryDetails;

Quiero enviar la variable de país de Form.tsx al archivo CountryDetails.tsx. como lo envio Estoy haciendo las operaciones de ruta en el archivo de índice. Intenté enviarlo como accesorios, también como estado, incluso usé link to lugar de la función de navegación. También usé history.push. Por favor ayuda.

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

0

¿Puedes probar esto?

 <form onSubmit={() => navigate('/country', { state={ country }, replace=true })}> {...} </form> const params = useParams() const { state } = params; // I think country inside state
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!