react

[React] Cannot destructure property 'basename' of 'React2.useContext(...)' as it is null.

킹king 2024. 1. 2. 15:18
반응형

 

Cannot destructure property 'basename' of 'React2.useContext(...)' as it is null.

 

Link를 썼더니 이런 오류가 뜰 때는 바깥에 라우터로 감싸주자.

 

1. BrowserRouter 추가

import { BrowserRouter, Link } from "react-router-dom";

// ...

return(
  <BrowserRouter>
    <div>
      <Link to="/"></Link>
    </div>
  </BrowserRouter>
)