-
Notifications
You must be signed in to change notification settings - Fork 232
Showing component only for authenticated user, but for every path, without rerendering each time path changes. #932
Comments
@adammo94 Try using the |
Ok, but still I do not know how to make component to show for all paths when logged in, without rerouting to "/login" (onAuthRequired does this) when not logged in. |
@adammo94 OK, I think I understand. You would like to have some UI that shows on all secured routes, but does not show on unsecured routes. The way it is defined here will cause problems because the component will also render on unsecured routes. This will probably break the callback route, which must be unsecured. In this case, I think it would be better to render the header UI based on the auth state, without using a route definition. Remove the route definition for "/" and put your |
I tried code below (ScreensMain already checks for authState) and then two bad things happen:
|
@adammo94 Several routes, including "/" have plain attribute
|
I'm submitting this issue for the package(s):
I'm submitting a:
Current behavior
So currently when I enter any unsecured route it reroutes to /login, I know this is happening due to SecureRoute path="/" with ScreensMain component not having 'exact' prop.
Expected behavior
My ScreensMain component contains navbar and topbar of my application and I would like it to be accessible for logged in users only, but also I DO NOT WANT it to rerender each time path changes.
Minimal reproduction of the problem with instructions
Extra information about the use case/user story you are trying to implement
My code:
Environment
node -v
): v12.19.0The text was updated successfully, but these errors were encountered: