dual-salmonD
Refine3y ago
19 replies
dual-salmon

Problems nesting resources and routes

I am trying to nest my child resource routes within the parents, but I am having difficulty doing so. The first I am having is that each resource object expects the parameter :id. This means if I have a nested resource I cant use :id because its already taken by the parent. The second issue is that, even if I don't need to use :id, for example, in my nested create route, the page wont load the element anyways. By this I mean, at the route /courses/show/:id/scenarios/create, it will just continue to display the /courses/show/:id page. I am using react router v6 for my routing. Here is my resources configuration, any help would be appreciated:
           resources={[
  {
    name: "courses",
    list: "/courses",
    create: "/courses/create",
    edit: "/courses/edit/:id",
    show: "/courses/show/:id",
 },
 {
    name: "scenarios",
    list: "/courses/show/:id",
    create: "/courses/show/:id/scenarios/create",
    edit: "/courses/show/:id/scenarios/edit/:scenarioId",
    show: "/courses/show/:id/scenarios/show/:scenarioId",
     meta: {
        parent: "courses",
        hide: true,
    },
 },
]}
Was this page helpful?