I am making a simple login app. I have public and private routes. And I also have a variable route that can access to both private and public users. So far I created routes from public and private users. But that variable route for both users is not accessible. How can I solve this issue. I am using router-dom v5
<Route path={"/forgot-password"}>
<ForgetPwd />
</Route>
<Route path={"/verifyEmail"}>
<EmailVarification />
</Route>
<Route path={"/recover-password"}>
<Recoverpassword />
</Route>
<PostProvider>
<Layout>
<PrivateRoutes path="/dashboard">
<Dashboard />
</PrivateRoutes>
</Layout>
</PostProvider>
<Route path="/:id?">
<Publicpage />
</Route>
I Think above question is not very clear. so I will explain my question more
<BrowserRouter>
<Switch>
<Route path={"/home"}>
<Home />
</Route>
<Route path={"/"}>
{/* I need to add some logic to Protect these routes */}
<Switch>
<Route path={"/about"}>
<About />
</Route>
</Switch>
</Route>
{/* This below route cannot access */}
<Route path={"/:id"}>
<PublicPage />
</Route>
</Switch>
</BrowserRouter>
I want to create simple react-router but I need public page to display data according to entered code name. And also I need to have some protected routes also. So I created some protected routes and my variable public route placed end of the routes So it will not clash with static routes. My question is after that protected route, react-router is not looking outside that scope. Below routes are not rendered