如何将悬念与React-Router-Dom V6使用?

发布于 2025-02-10 10:05:09 字数 918 浏览 0 评论 0原文

我正在尝试将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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文