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

108
Views
React Router Dom v6 navegar no es una función

Hola a todos, soy nuevo en React y tengo un problema al usar el enlace useNavigate de react-router-dom v6. Estoy tratando de agregar la funcionalidad onClick a los botones para cambiar la ruta usando navegar, pero cada vez que hago clic en mi botón aparece este error Uncaught TypeError: navigate is not a function . Este es mi código simplificado si alguien puede ayudar.

Nav.js

 const Nav = () => { const { navigate } = useNavigate(); const itemsList = [ { text: "Home", icon: <InboxIcon />, onClick: () => navigate("/") }, { text: "Contact", icon: <MailIcon />, onClick: () => navigate("/contact") }, { text: "About", icon: <InboxIcon />, onClick: () => navigate("/about") }, ]; return ( <List> {itemsList.map((item, index) => { const { text, icon, onClick } = item; return ( <ListItem button key={text} onClick={onClick}> {icon && <ListItemIcon>{icon}</ListItemIcon>} <ListItemText primary={text} /> </ListItem> ); }) </List>

Aplicación.js

 function App() { return ( <div className="App"> <Nav /> <Routes> <Route exact path="/" element={<Main />} /> <Route exact path="/contact" element={<contact/>} /> <Route exact path="/about" element={<about/>} /> </Routes> </div> ); }

índice.js

 ReactDOM.render( <React.StrictMode> <BrowserRouter> <App /> </BrowserRouter> </React.StrictMode>, document.getElementById("root") );
about 4 years ago · Juan Pablo Isaza
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!