Hi everyone, I have a question that I think is fairly simple. I have an atom that holds my application state. Instead of referencing it directly from all of my components / functions, I’m passing it around as an argument. It has a key indicating whether or not the user is logged in. When routing to my logout route, I’d like to remove that value from the atom and redirect the user back to the login page. However, I’m having issues on figuring out where I should be doing this at. Does anyone have any suggestions?
I’m using secretary / accountant in addition to rum
Here’s my code snippet:
(rum/defc logout < rum/reactive [app-state-atom]
[:div "logging out"])
(defn render-logout [app-state-atom]
(swap! app-state-atom dissoc :token)
(accountant/navigate! "#/login")
(logout app-state-atom))
I managed to fix my issue. I had created a function that was calling rum/mount
inside each of my defroute
definitions. So calling secretary/dispatch!
was building a brand new component and calling rum/mount
. I updated my app to instead call rum/mount
once at the beginning to mount a single component which uses rum/react
on my app-state. This component now calls secretary/dispatch!
which simply returns a partial function for creating the necessary rum component