我正在开发一个 React 应用程序。我想使用 useLocation 但它抛出这个错误
类型错误:useContext(...) 未定义
我的代码
import { AnimatePresence, motion } from 'framer-motion'
function App() {
const location = useLocation();
return (
<div className="app">
<Router>
<Switch >
<AnimatePresence exitBeforeEnter>
<Route path='/' exact component={Home} />
<Route path='/about' component={About} />
<Route path='/projects' component={Projects} />
<Route path='/contact' component={Contact} />
<Route path='/resume' component={Resume} />
</AnimatePresence>
</Switch>
</Router>
</div>