Uncaught Error: Invariant failed: You should not use <Link> outside a <Router>

Juyeon Lee·2022년 6월 23일
0

에러

목록 보기
7/31

이 에러 나올때는 링크 태그 쓴 컴포넌트가
라우터 밖에 있을 때 그런거니까
라우터 안으로 옮겨주면 된다.

const App = () => {
  return (
    <div className="ui container">
      <Header />

      <BrowserRouter>
        <div>
          <Route path="/" exact component={StreamList} />
          <Route path="/streams/new" exact component={StreamCreate} />
          <Route path="/streams/edit" exact component={StreamEdit} />
          <Route path="/streams/delete" exact component={StreamDelete} />
          <Route path="/streams/show" exact component={StreamShow} />
        </div>
      </BrowserRouter>
    </div>
  );
};

여기에서 오류난걸
이렇게 바꿔준다

const App = () => {
  return (
    <div className="ui container">
      <BrowserRouter>
        <Header />
        <div>
          <Route path="/" exact component={StreamList} />
          <Route path="/streams/new" exact component={StreamCreate} />
          <Route path="/streams/edit" exact component={StreamEdit} />
          <Route path="/streams/delete" exact component={StreamDelete} />
          <Route path="/streams/show" exact component={StreamShow} />
        </div>
      </BrowserRouter>
    </div>
  );
};

0개의 댓글