WEB/REACT

[REACT] 잘못된 주소 처리 NotFound

자바칩 프라푸치노 2021. 9. 29. 22:47

import React, {useCallback, useEffect, Suspense, lazy } from "react";
import { ConnectedRouter } from "connected-react-router";
import { Route, Switch, useLocation } from "react-router-dom";
import { history } from "../redux/configStore";
//...
import NotFound from "../pages/NotFound";


function App() {
  return (
   
    <ConnectedRouter history={history}>
    <Switch >
     //...
      <Route path="/" exact component={Main} />
        <Route component={NotFound} />
    </Switch>
    <Footer/>
    </ConnectedRouter>
  );
}

export default App;

 

다른 페이지들은 path를 지정해주는데 Notfound는 path를 지정 안해주면 됨!

다음 게시물에서는 Connected router과 React의 렌더에 대해서 알아보자!

728x90