Reitit.frontend navigate back


#1

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?


#2

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


#3

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)


#4

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.