0

I migrated react routing from V5 to V6 and I'm using useRoutes hook. I followed the below example from the docs. https://stackblitz.com/github/remix-run/react-router/tree/main/examples/route-objects?file=src/App.tsx

I need to import the below from another central config file.

 let routes: RouteObject[] = [
    {
      path: "/login",
      element: <Login />,
      children: []
    },
    {
      path: "/forgot-password",
      element: <ForgotPassword />,
      children: []
    },
    {
      path: "/complete-profile",
      element: <CompleteUserProfile />,
      children: []
    },
    {
      path: "/otp-confirm",
      element: <OtpConfirmPage />,
      children: []
    },
    {
      path: '/change-password',
      element: <ChangePassword />,
      children: []
    },
    {
      path: '/sign-up',
      element: <SignupRequest />,
      children: []
    },
    {
      path: '/additional-document-upload',
      element: <UploadAdditionalDocuments />,
      children: []
    },
    {
      path: '/additional-document-upload/link-expired',
      element: <UploadAdditionalDocumentsLinkExpired />,
      children: []
    },
    {
      path: '/additional-document-upload/file-uploaded',
      element: <UploadAdditionalDocumentsLinkExpired />,
      children: []
    },
    {
      path: "/",
      element: (
        <RequireAuth>
          <Dashboard />
        </RequireAuth>
      ),
      children: [
        {
          path: '/admin',
          element: <AdminPage />,
          children: [
            {
              path: '/admin/dashboard',
              element: <AdminDashboard />,
            },
            {
              path: '/admin/account-requests',
              element: <AccountRequestsList />
            },
          ]
        },
        {
          path: '/broker',
          element: <BrokerPage />,
        },
        {
          path: '/agent',
          element: <AgentPage />,
        },
      ]
    },
  ];

    const element = useRoutes(routes);

Currently, I have placed this in App.tsx, and the file already looks messy.

Is there any way where I can move it to another file and import it to App.tsx.

Thanks in advance

Kewin Fernando
  • 240
  • 4
  • 16

0 Answers0