An index route cannot have child routes. Why i can’t pass child to index? I want 3 or 4 level nested routing in my app

NOTE:: this is a scenario that i’m describing here as i need same in real app. in my actual app, i need 3 or 4 level nested routing. i’m using index because when i’ll visit the tab list1, url would be /profile and list1 should be there by default and list1 should render productList as its child.
if i go to list2 tab, url will /profile/list2/items and list2 should render with productList and same for list3.
if i go to list3 tab, url will /profile/list3/items and list3 should render with productList.

productList is rendering a Product component. by clicking on that component, a modal will be open along with ProductDetails component.
And wheneven i click on Product modal will be open with ProductDetails component. and then url will be localhost://5173/product/productId

this is the same stuff as if we visit profile page on instagram.
i hove you people can understand the scenario i want to create.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>
export default function App() {
return (
<div className="App">
<h3 className="text-red-500 font-bold">App</h3>
<Routes>
<Route path="/" element={<Home />} />
<Route path="profile" element={<Profile />}>
<Route index element={<List1 />}>
<Route path="/profile/list1/items" element={<ProductList />} />
</Route>
<Route index path="list2" element={<List2 />}>
<Route path="/profile/list2/items" element={<ProductList />} />
</Route>
<Route index path="list3" element={<List2 />}>
<Route path="/profile/list3/items" element={<ProductList />} />
</Route>
</Route>
</Routes>
</div>
);
}
</code>
<code> export default function App() { return ( <div className="App"> <h3 className="text-red-500 font-bold">App</h3> <Routes> <Route path="/" element={<Home />} /> <Route path="profile" element={<Profile />}> <Route index element={<List1 />}> <Route path="/profile/list1/items" element={<ProductList />} /> </Route> <Route index path="list2" element={<List2 />}> <Route path="/profile/list2/items" element={<ProductList />} /> </Route> <Route index path="list3" element={<List2 />}> <Route path="/profile/list3/items" element={<ProductList />} /> </Route> </Route> </Routes> </div> ); } </code>

export default function App() {
  return (
    <div className="App">
      <h3 className="text-red-500 font-bold">App</h3>
      <Routes>
        <Route path="/" element={<Home />} />
        <Route path="profile" element={<Profile />}>
          <Route index element={<List1 />}>
            <Route path="/profile/list1/items" element={<ProductList />} />
          </Route>
          <Route index path="list2" element={<List2 />}>
            <Route path="/profile/list2/items" element={<ProductList />} />
          </Route>
          <Route index path="list3" element={<List2 />}>
            <Route path="/profile/list3/items" element={<ProductList />} />
          </Route>
        </Route>
      </Routes>
    </div>
  );
}

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>export default function ProductList() {
return (
<ul className="flex items-center gap-x-3 *:cursor-pointer">
{products.map((product) => (
<Product key={product.id} item={product} />
))}
</ul>
);
}
</code>
<code>export default function ProductList() { return ( <ul className="flex items-center gap-x-3 *:cursor-pointer"> {products.map((product) => ( <Product key={product.id} item={product} /> ))} </ul> ); } </code>
export default function ProductList() {
  return (
    <ul className="flex items-center gap-x-3 *:cursor-pointer">
      {products.map((product) => (
        <Product key={product.id} item={product} />
      ))}
    </ul>
  );
}
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>export default function Product({ item }) {
const navigate = useNavigate();
return (
<ModalProvider>
<Modal.Open opens="product-details">
<div className="w-52 h-52 border border-blue-400 flex items-center justify-center">
{item?.name}
</div>
</Modal.Open>
<Modal.Window name="product-details">
<ProductDetails />
</Modal.Window>
</ModalProvider>
);
}
</code>
<code>export default function Product({ item }) { const navigate = useNavigate(); return ( <ModalProvider> <Modal.Open opens="product-details"> <div className="w-52 h-52 border border-blue-400 flex items-center justify-center"> {item?.name} </div> </Modal.Open> <Modal.Window name="product-details"> <ProductDetails /> </Modal.Window> </ModalProvider> ); } </code>
export default function Product({ item }) {
  const navigate = useNavigate();
  return (
    <ModalProvider>
      <Modal.Open opens="product-details">
        <div className="w-52 h-52 border border-blue-400 flex items-center justify-center">
          {item?.name}
        </div>
      </Modal.Open>

      <Modal.Window name="product-details">
        <ProductDetails />
      </Modal.Window>
    </ModalProvider>
  );
}
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>export default function ProductDetails() {
return (
<div className="border flex-col border-blue-400 w-52 h-32 flex items-center justify-center">
<h2>Name: {product.name}</h2>
<h3>Category: {product.category}</h3>
<h4>Price: {product.price}</h4>
</div>
);
}
</code>
<code>export default function ProductDetails() { return ( <div className="border flex-col border-blue-400 w-52 h-32 flex items-center justify-center"> <h2>Name: {product.name}</h2> <h3>Category: {product.category}</h3> <h4>Price: {product.price}</h4> </div> ); } </code>
export default function ProductDetails() {
  return (
    <div className="border flex-col border-blue-400 w-52 h-32 flex items-center justify-center">
      <h2>Name: {product.name}</h2>
      <h3>Category: {product.category}</h3>
      <h4>Price: {product.price}</h4>
    </div>
  );
}

here is accessible link to sandbox for demo project;

i’ve visited react-router-dom docs, go through some articles even visited stackoverflow previous questions but didn’t found any solution to my problem

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật