当前位置:网站首页>Uncaught Error: [About] is not a <Route> component. All component children of <Routes> must be a <Ro
Uncaught Error: [About] is not a <Route> component. All component children of <Routes> must be a <Ro
2022-06-25 02:29:00 【Gongsun yuaner】
When I put react-router-dom from v5 Upgrade to v6, This error message appears .
My code :
index.js File code
import React from "react"
import ReactDOM from "react-dom"
import "./assets/main.css"
import App from "./App"
import { BrowserRouter } from "react-router-dom"
import { AuthContextProvider } from "./context/AuthContext"
ReactDOM.render(
<React.StrictMode>
<AuthContextProvider>
<BrowserRouter>
<App />
</BrowserRouter>
</AuthContextProvider>
</React.StrictMode>,
document.getElementById("root")
)
App.js File code
import React, { Suspense } from "react"
import { Routes, Route } from "react-router-dom"
import "./App.css"
import { Helmet } from "react-helmet"
// custom components
import SideBar from "./components/layouts/SideBar"
import Navbar from "./components/layouts/Navbar"
import Footer from "./components/layouts/Footer"
import Feedback from "./components/feedback/Feedback"
import useGaTracker from "./hooks/useGaTracker"
import LottieAnimation from "./components/smallComponents/LottieAnimation"
// loader
import rocketLoader from "./assets/animated_illustrations/loader.json"
// lazy loading components
const Dashboard = React.lazy(() => import("./components/dashboard/Dashboard"))
const ChallengesList = React.lazy(() => import("./components/challenges/ChallengesList"))
const ChallengeDetails = React.lazy(() =>
import("./components/challenges/ChallengeDetails")
)
const Resources = React.lazy(() => import("./components/resources/Resources"))
const Roadmaps = React.lazy(() => import("./components/roadmaps/Roadmaps"))
const SolutionList = React.lazy(() => import("./components/solutions/SolutionList"))
const MySolutions = React.lazy(() => import("./components/MySolutions/MySolutions"))
const App = () => {
useGaTracker()
return (
<>
<Helmet>
<title>CODINGSPACE - Learn by Building Web and Mobile Apps</title>
</Helmet>
<div className="relative grid min-h-screen md:grid-cols-layout-tablet xl:grid-cols-layout-desktop grid-rows-layout-desktop md:gap-6">
<Navbar />
<SideBar />
<Suspense
fallback={
<div className="sm:ml-0 pr-5 py-52 row-start-2 row-end-3 col-start-1 md:col-start-2 col-end-3 place-self-center">
<LottieAnimation
animationDataFile={rocketLoader}
height={100}
width={100}
/>
</div>
}
>
<Routes>
<Route exact path="/">
<Dashboard />
</Route>
<Route path="/challenges">
<ChallengesList />
</Route>
<Route path="/challenge/:id">
<ChallengeDetails />
</Route>
<Route path="/resources">
<Resources />
</Route>
<Route path="/roadmaps">
<Roadmaps />
</Route>
<Route path="/solutions">
<SolutionList />
</Route>
<Route path="/mysolutions">
<MySolutions />
</Route>
</Routes>
</Suspense>
<Feedback />
<Footer />
</div>
</>
)
}
export default App
Solution
stay v6 in , You should treat components as “ Elements ” Pass on , Like this :
<Route path="/" element={<Dashboard/>}>
Or protected route :
<Route
path="home"
element={
<ProtectedRoute user={user}>
<Home />
</ProtectedRoute>
}
/>
...
</Routes>
边栏推荐
- Intranet learning notes (5)
- 【STL源码剖析】STL六大组件功能与运用(目录)
- 同花顺是正规平台吗?同花顺开户安全吗
- It is said that Yijia will soon update the product line of TWS earplugs, smart watches and bracelets
- 把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(3)—— 把数据库设置为归档模式
- 内网学习笔记(7)
- [STL source code analysis] configurator (to be supplemented)
- |How to analyze bugs? Professional summary and analysis
- Can automate - 10k, can automate - 20K, do you understand automated testing?
- 把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(4)—— 修改 oracle11g rac 集群的 scanIP
猜你喜欢

jwt

都2022年了,你还不了解什么是性能测试?

Use of hashcat

Exploring the mystery of C language program -- C language program compilation and preprocessing

转行软件测试2年了,给还在犹豫的女生一点建议

常用的软件测试工具清单,请查收。

文件系统 -- 磁盘基础知识和FAT32文件系统详细介绍

random list随机生成不重复数

3年测试经验,连简历上真正需要什么都没搞明白,张口就要20k?

After reciting the eight part essay, I won the hemp in June
随机推荐
Hashcat 的使用
Random list random generation of non repeating numbers
【FPGA】串口以命令控制温度采集
Intranet learning notes (7)
Using qdomdocument to manipulate XML files in QT
Sumati gamefi ecological overview, element design in the magical world
如何通过EasyCVR接口监测日志观察平台拉流情况?
【STL源码剖析】配置器(待补充)
Left hand dreams right hand responsibilities GAC Honda not only pays attention to sales but also children's safety
Please run IDA with elevated permissons for local debugging.
Viewing MySQL password on Linux_ MySQL forgets password "suggestions collection" under Linux
中信证券手机开户是靠谱的吗?安全吗
Uncaught Error: [About] is not a <Route> component. All component children of <Routes> must be a <Ro
Intranet learning notes (6)
What is the reason for the disconnection of video playback due to the EHOME protocol access of easycvr platform?
Jetson Nano 从入门到实战(案例:Opencv配置、人脸检测、二维码检测)
Convert string array to list collection
[I.MX6UL] U-Boot移植(六) 网络驱动修改 LAN8720A
Basic layout -qhboxlayout class, qvboxlayout class, qgridlayout class
Use of hashcat