Reitit.frontend navigate back

I’m using Reagent with reitit.frontend as the router. I have forms that need to go to the previous page when a button is clicked. I haven’t been able to find an example of how to do that. In Vue, it’s done like

this.$router.go(-1)

How is that done with reitit?

Haven’t used reitit.frontend but can’t you just call (.back js/window.history)?

Indeed, just calling window history methods should work. My understanding is that Vue also does just this: https://github.com/vuejs/vue-router/blob/v2.0.3/src/history/html5.js#L41

(.go js/window.history -1)
;; or
(.back js/window.history)

For now, I don’t see reason to add functions for this to Reitit, but we should mention this in the docs. (Added: https://github.com/metosin/reitit/commit/4cd63a4e62cd211e624da2d9b7c2869bc2619647)

3 Likes

OK, cool That’s what I did to get it working. I thought I had read at some point that Vue and React didn’t want you to navigate outside of their routers because of internal state or something. Maybe I’m not remembering that entirely correctly, or it doesn’t matter here.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.