小编use*_*726的帖子

BrowserRouter 导致无效的挂钩调用。钩子只能在函数组件体内调用

使用react-router-dom版本6时出现以下错误:

\n
Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\n
Run Code Online (Sandbox Code Playgroud)\n

据说我的BrowserRouter是问题,这似乎表明 React 和渲染器不匹配。但是,我找不到任何问题。下面是导致错误的代码片段:

\n
import React from 'react';\nimport './App.css';\nimport { BrowserRouter, Route, …
Run Code Online (Sandbox Code Playgroud)

javascript typescript reactjs react-router react-router-dom

10
推荐指数
1
解决办法
5203
查看次数