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

118
Views
React Router Dom v6 navigate is not a function

Hey all I'm new to React and having an issue using react-router-dom v6 useNavigate hook. I'm trying to add onClick functionality to buttons to change the path using navigate but anytime I click my button this error comes up Uncaught TypeError: navigate is not a function. This is my simplified code if anyone can help.

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>

App.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>
  );
}

index.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!