Home > Mobile >  I have react app version 18 and i want install react-router dom version 5
I have react app version 18 and i want install react-router dom version 5

Time:09-29

when i install react-router dom version 5 error appers. I assume the error is caused by my react version, what can I do to fix it?

$ npm install [email protected]
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   peer react@">=16.8.0" from @emotion/[email protected]
npm ERR!   node_modules/@emotion/react
npm ERR!     @emotion/react@"^11.8.1" from [email protected]
npm ERR!     node_modules/react-select
npm ERR!       peer react-select@"^5.0.0" from [email protected]

CodePudding user response:

Please try to run the npm command with --force, or --legacy-peer-deps

EXAMPLE: npm install react-router-dom --force

CodePudding user response:

I'm encountering a new problem that when I want to switch between routers I have to do a refresh

import "../src/assets/sass/global.scss";
import { Header } from "./components/Header";
import { HashRouter as Router, Route, Switch } from "react-router-dom";
import { Favorite } from "./pages/Favorite";
import { WeatherApp } from "./pages/WeatherApp";

export function App() {
  return (
    <Router>
      <div className="app">
        <Header />
        <main className="container-app">
          <Switch>
            <Route component={Favorite} path="/favorite" />
            <Route component={WeatherApp} path="/" />
          </Switch>
        </main>
      </div>
    </Router>
  );
}```
  • Related