I am trying to import useHistory from 'react-router-dom', however, I get this error: import error: 'useHistory' is not exported from 'react-router-dom'.
I have checked other answers as well such as Attempted import error: 'useHistory' is not exported from 'react-router-dom' this but to no avail. My package.json looks like this
I am using useHistory as such,
import React from 'react';
import { useState, useEffect } from 'react';
import { useHistory } from 'react-router-dom';
export default function Login(){
const history = useHistory();
console.log(history)
}
However, this line works fine and does not cause import issues from react-router-dom.
import {BrowserRouter as Router, Switch, Route} from 'react-router-dom'
Does anyone have an idea how to solve this issue? much appreciated.