当前位置:网站首页>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>
边栏推荐
- 疫情防控,居家办公,网上授课之心得 | 社区征文
- 测试/开发程序员,30而立,你是否觉得迷茫?又当何去何从......
- LINQ 查询(3)
- Multimodal emotion recognition_ Research on emotion recognition based on multimodal fusion
- 内网学习笔记(7)
- 把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(3)—— 把数据库设置为归档模式
- MCN机构遍地开花:博主和作者要谨慎签约、行业水很深
- yarn : 无法加载文件 C:\Users\xxx\AppData\Roaming\npm\yarn.ps1,因为在此系统上禁止运行脚本
- Please run IDA with elevated permissons for local debugging.
- Rod and Schwartz cooperated with ZhongGuanCun pan Lianyuan Institute to carry out 6G technology research and early verification
猜你喜欢
文件系统 -- 磁盘基础知识和FAT32文件系统详细介绍
做软件安全测试的作用,如何寻找软件安全测试公司出具报告?
保险APP适老化服务评测分析2022第06期
会自动化—10K,能做自动化—20K,你搞懂自动化测试没有?
ProcessOn制作ER过程(自定义)
【Proteus仿真】Arduino UNO+数码管显示4x4键盘矩阵按键
折叠屏将成国产手机分食苹果市场的重要武器
EasyCVR国标协议接入的通道,在线通道部分播放异常是什么原因?
DDD concept is complex and difficult to understand. How to design code implementation model in practice?
如何通过EasyCVR接口监测日志观察平台拉流情况?
随机推荐
Investigation on key threats of cloud computing applications in 2022
【Proteus仿真】Arduino UNO+数码管显示4x4键盘矩阵按键
疫情防控,居家办公,网上授课之心得 | 社区征文
Kaggle 专利匹配比赛金牌方案赛后总结
It's 2022, and you still don't know what performance testing is?
Migrate Oracle database from windows system to Linux Oracle RAC cluster environment (4) -- modify the scanip of Oracle11g RAC cluster
File system - basic knowledge of disk and detailed introduction to FAT32 file system
計網 | 【四 網絡層】知識點及例題
Folding screen will become an important weapon for domestic mobile phones to share the apple market
Dirvish Chinese document of vim
Intranet learning notes (6)
把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(2)——将数据库转换为集群模式
[day 26] given the ascending array nums of n elements, find a function to find the subscript of target in nums | learn binary search
How do the TMUX color palette work?
When an interface has an exception, how do you analyze the exception?
LINQ query (3)
Resolution of cross reference in IDA
一线城市软件测试工资——你拖后腿了吗
Exploring the mystery of C language program -- C language program compilation and preprocessing
Intranet learning notes (5)