1

This is how I'm assigning routes.

Routes = [
{
    path: "/Hibachi/:id?",
    component: HibachiGrill,
    title: "Hibachi",
    icon: <TableOutlined />,
    exact: true,
  },
{
    path: "/Barfloor",
    component: BarFloor,
    title: "Barfloor",
    icon: <RiDashboardFill />,
    exact: true,
  },
];

I'm calling the routes like this.

       <LayoutAnt className="content">
          <Switch>
            {Routes.map((route, index) => (
              <Route
                key={index}
                exact={route.exact}
                path={route.path}
                component={route.component}
              />
            ))}
          </Switch>
        </LayoutAnt>

My question is when I don't pass any parameter in the hibachi component I get this as result :id I have tried putting a ? but I'm still facing the same problem.

1 Answer 1

1

It Works fine just see this sandbox Simple routing with your routes.

Also as you didn't mention how you access the parameters, i suppose you didn't use he useParams hook, that's why you might be getting unwanted props in your component.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.