Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: 'useNavigate' is not exported from 'react-router-dom'

When trying to import useNavigate from react-router-dom, I get the following error:

Attempted import error: 'useNavigate' is not exported from 'react-router-dom'.

My Import statement:

import { useNavigate } from 'react-router-dom';
like image 657
John Sneijder Avatar asked Oct 27 '22 17:10

John Sneijder


2 Answers

You are trying to use the latest features of react-router.
Please make sure that you installed the [email protected] .

It is React Router v6 which gives you a useNavigate hook

Please refer here for further reading from the React Router team

Two quick ways to check the version:

  • Verify from the package.json file
  • Run npm list --depth=0 to view the various packages in your project
like image 166
MwamiTovi Avatar answered Nov 15 '22 12:11

MwamiTovi


I faced issue as like this: "useNavigate is not exported from 'react-router-dom"

My solution - I uninstalled the react-router-dom and I have reinstalled it... now this issue is resolved for me..

like image 20
Aliksm Shaik Avatar answered Nov 15 '22 12:11

Aliksm Shaik