Replies: 1 comment 3 replies
-
Why do you need two separate routers for something which can implemented entirely in loaders? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to create public and private routes in React application while using react-router-dom and
createBrowserRouter
.An simple examples, what I would like to have but you can not define
createBrowserRouter
in the render lifecycle or have conditional routes. What is the solution here for both of those examples?While I could use
loader
to have "conditional" rendering but how I would access the context data,as
useSessionUser()
is tied to component lifecycle; Is the only solution to use a external store?What about when I would like to have different index(element) routes in private and public routes?
Important to note:
createBrowserRouter
must be outside the Component render lifecycle and be treated as singleton. Link to maintainer answerBeta Was this translation helpful? Give feedback.
All reactions