I'm building an app on top of re-frame default template.
I have following secretary route:
(defroute "/users/:id" []
(re-frame/dispatch [:set-active-panel :user-panel])
I want to access id
parameter from URL in my reagent component. The only way of achieving it that I've found is setting it to db
. Something like:
(defroute "/users/:id" [id]
(re-frame/dispatch [:set-user-id id])
(re-frame/dispatch [:set-active-panel :user-panel])
This will definitely pollute my db and such approach seems to be weird for me as I used to write something like this in the react (with react-router):
<Route path="/user/:id" component={MyComponent}>
// object with params automatically attached as props to MyComponent
So what is the correct way to broadcast secretary URL parameters to reagent component?
UPD: In comments there's a link to github discussion of this problem. Ones refer to setting URL params to db as a correct way. Anyways, I don't really like it. It causes a lot more complexity (setting params, subscribing to them, unsetting). And I don't like to think about URL params as app state. Is there any hack or something?