如何将悬念与React-Router-Dom V6使用?
我正在尝试将React-Router-Dom从V5迁移到V6,并且遇到了麻烦,这是我使用悬挂
<Suspense
fallback={
<div className="center-div">
<LoadingDots />
</div>
}
>
<Routes>
{routes.map((route, index) => (
<Route
path={route.path}
key={route.path}
element={lazy(() => import("./features/apps/AppsListPage"))} //it is route.component but for simplify example i'm show it like this
/>
))}
</Routes>
</Suspense>
有人告诉我,有人可以告诉我为什么浏览器为什么浏览器返回我这种错误?
index.tsx:13 Error: Objects are not valid as a React child (found: object with keys {$$typeof, _payload, _init}). If you meant to render a collection of children, use an array instead.
我认为它是由element
prop中使用懒惰
引起的,但是我可以解决此问题吗?
感谢您的帮助!
I'm trying to migrate react-router-dom from v5 to v6 and I'm having a trouble, here is my implementation with using Suspense
<Suspense
fallback={
<div className="center-div">
<LoadingDots />
</div>
}
>
<Routes>
{routes.map((route, index) => (
<Route
path={route.path}
key={route.path}
element={lazy(() => import("./features/apps/AppsListPage"))} //it is route.component but for simplify example i'm show it like this
/>
))}
</Routes>
</Suspense>
can someone tell me why browser return me this kind of error?
index.tsx:13 Error: Objects are not valid as a React child (found: object with keys {$typeof, _payload, _init}). If you meant to render a collection of children, use an array instead.
I think that it caused by using lazy
in element
prop, but can i fix this?
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论