Determine if a navigation would go to the previous page.
Hey!
I am trying to wrap the
Link component such that if the link would cause a navigation to what was the previous page, instead it will run history.back(). My idea is to store the last location locally, figure out what the next location will be and then either return the router Link or do a history back. I've got as far as this:
but in order to implement goBack I need to somehow calculate the location from the props that will be passed to Link without Link actually being clicked. I've looked through the router API, but can't figure out how to do do this.
Is there a function somewhere to help me, or is there a better way to achieve this?0 Replies