You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm wondering if there is a recommended way to set custom data on a route, and access that in the router subscription handler.
Example:
<Routepath="/top-secret"requiresAuthentication={true}><SuperSecretRoute></Route>router.subscribe((navigationData)=>{if(navigationData.requiresAuthentication){// force the user to re-authenticate}}
My use case is that I would like to have certain Routes trigger an authentication check, and launch a modal if the user is unauthenticated. I read the docs and wrapping the routes in a {# if authenticated } is nice, but not sufficient. One relevant point here is that I would like to avoid using route.meta, since it looks like this only works from within the route. I know that route.meta could be used from within the Route, but it seems hacky (and error-prone) to have each route responsible for performing this type of check.
I imagine being able to pass custom navigation data would be useful in other scenarios as well — it would add quite a bit of flexibility.
Any thoughts on whether this is something Tinro should handle? Or if not, is there a recommended way to do something similar? Thanks
The text was updated successfully, but these errors were encountered:
drewrygh
changed the title
Setting custom values is navigationData
Setting custom values in navigationData
Dec 3, 2021
I would also like to associate extra data with each route and be able to access that data for the currently selected route. I'm currently doing it like this, but it's pretty hacky:
I'm wondering if there is a recommended way to set custom data on a route, and access that in the
router
subscription handler.Example:
My use case is that I would like to have certain Routes trigger an authentication check, and launch a modal if the user is unauthenticated. I read the docs and wrapping the routes in a
{# if authenticated }
is nice, but not sufficient. One relevant point here is that I would like to avoid using route.meta, since it looks like this only works from within the route. I know that route.meta could be used from within the Route, but it seems hacky (and error-prone) to have each route responsible for performing this type of check.I imagine being able to pass custom navigation data would be useful in other scenarios as well — it would add quite a bit of flexibility.
Any thoughts on whether this is something Tinro should handle? Or if not, is there a recommended way to do something similar? Thanks
The text was updated successfully, but these errors were encountered: