使用react中的router v6版本踩坑记录。
按照A is only ever to be used as the child of element, never rendereddirectly.Please wrap your in a 这篇文章设置完最新版本的路由后,出现了这样的报错,useRoutes() may be used only in the context of a <Router> component.,经过查询之后,从这里找到了解决答案,useRoutes() may be used only in the context of a component.
解释如下:

在这里插入图片描述
最后的解决方法,最路由标签最外层再包裹一层BrowserRouter标签,
这是我的index.js文件,在这里插入图片描述
这是我的App.js文件,在这里插入图片描述

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐