App.js
import React, {useEffect, useState} from 'react';
import axios from 'axios';
import {Route, Router, Switch} from "react-router-dom";
import LandingPage from "./Components/LandingPage";
function App() {
return (
<Router>
<Switch>
<Route exact path="/" component={LandingPage}/>
</Switch>
</Router>
);
}
export default App;
해당 코드를 작성하여 실행하니
export 'Switch' (imported as 'Switch') was not found in 'react-router-dom' 오류가 발생했다.

이는 Switch를 찾을 수 없다는 오류이다.
왜냐하면 버전6 이상에서 Switch가 삭제되었기 때문이다.
터미널에 다음과 설치했던 react-router-dom을 삭제하고 @5로 재설치하자
npm uninstall react-router-dom
npm install react-router-dom@5
'React > React 오류 창고' 카테고리의 다른 글
[리액트 + 스프링 연동] CORS 오류 해결 (0) | 2023.04.09 |
---|---|
[리액트] Cannot read properties of undefined (reading 'location') (0) | 2023.04.09 |
App.js
import React, {useEffect, useState} from 'react';
import axios from 'axios';
import {Route, Router, Switch} from "react-router-dom";
import LandingPage from "./Components/LandingPage";
function App() {
return (
<Router>
<Switch>
<Route exact path="/" component={LandingPage}/>
</Switch>
</Router>
);
}
export default App;
해당 코드를 작성하여 실행하니
export 'Switch' (imported as 'Switch') was not found in 'react-router-dom' 오류가 발생했다.

이는 Switch를 찾을 수 없다는 오류이다.
왜냐하면 버전6 이상에서 Switch가 삭제되었기 때문이다.
터미널에 다음과 설치했던 react-router-dom을 삭제하고 @5로 재설치하자
npm uninstall react-router-dom
npm install react-router-dom@5
'React > React 오류 창고' 카테고리의 다른 글
[리액트 + 스프링 연동] CORS 오류 해결 (0) | 2023.04.09 |
---|---|
[리액트] Cannot read properties of undefined (reading 'location') (0) | 2023.04.09 |