Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
Problem using useRoutes when redirecting with params

I am trying to set up my project for the first time using useRoutes and lazy loading with children. But I am having a problem that it won't load the children when redirected to that site? The Home page works perfectly fine.

https://codesandbox.io/s/great-rgb-ippuob?file=/src/Page/Home/index.js Home path="/"

import React from "react";
import { Link } from "react-router-dom";
const Home = () => {
  return (
    <>
      <h1>Hello Welcome to my beauty page</h1>
      <Link to="/1">click me</Link>
    </>
  );
};
export default Home;

Children:

import React from "react";
import { useParams } from "react-router-dom";
const Id = () => {
  const { id: loadingId } = useParams();
  return <h1>Right now you are on the side of: {loadingId}</h1>;
};
export default Id;

App.js:

import "./styles.css";
import Route from "./Routes";
import { Suspense } from "react";
export default function App() {
  return (
    <>
      <div className="App">
        <Suspense fallback={<p>Loading...</p>}>
          <Route />
        </Suspense>
      </div>
    </>
  );
}

Routes:

import { useRoutes } from "react-router-dom";
import React from "react";
export default function Router() {
  return useRoutes([
    {
      path: "/",
      element: <Home />,
      children: [{ path: "/:id", element: <Id /> }]
    }
  ]);
}
const Home = React.lazy(() => import("./Page/Home"));
const Id = React.lazy(() => import("./Page/Id"));

And in Index I have

<BrowserRouter>
      <App />
    </BrowserRouter>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You should add <Outlet /> in Layout/Parent component (Home for you)

const Home = () => {
  return (
    <>
      <h1>Hello Welcome to my beauty page</h1>
      <Link to="/1">click me</Link>
      <Outlet />
    </>
  );
};
export default Home;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!