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

148
Views
react-route-dom v6 TypeError: no se pueden leer las propiedades de undefined (leyendo 'estado')

Tengo problemas para pasar el estado al destino del componente especificado en Navegar.

 "react": "~18.1.0", "react-router-dom": "^6.3.0",

enviar ${address} válida

  • de Wallet.js
 import { useNavigate } from "react-route-dom"; const Wallet = ({ address, amount, symbol, destroy }) => { const navigate = useNavigate(); return ( <div> <button> onClick={() => navigate("/booked", { state: { address: `${address}` } }) } </button> </div> ); };
  • a RoomManagement.js
 import { useLocation } from "react-router-dom"; const RoomManagement = () => { const { location } = useLocation(); console.log("get address: ", location); }

Pero en la consola:

ingrese la descripción de la imagen aquí

He intentado acceder, pero me da error.:

ingrese la descripción de la imagen aquí

¿Qué habría que modificar?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

location es el objeto devuelto por el useLocation . entonces el state sería desestructurado desde location .

Ejemplos:

 const RoomManagement = () => { const location = useLocation(); useEffect(() => { console.log("get address: ", location.state?.address); }, [location]); ... }

o

 const RoomManagement = () => { const { state } = useLocation(); useEffect(() => { console.log("get address: ", state?.address); }, [state]); ... }
about 4 years ago · Santiago Trujillo 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!