4.0.0
Can't access router history to push state.
Attempt to access programmatically the ability to change routing.
history.push (path) is what I would expect to push to a new route
alternatively history.replaceState (path) etc.
history is not available, confused as to if I need to import a library for this.
I should note, previous versions of RR contained these docs: https://github.com/ReactTraining/react-router/blob/master/docs/guides/NavigatingOutsideOfComponents.md
It appears I can access the router methods I need through context, however I was under the impression that using context was an anti pattern and would be deprecated?
We can't prevent its use, only discourage it. You might be interested in react-history for a declarative means to issue history actions. It's pretty neat.
@timdorr so what's the correct way to redirect in V4 from redux-saga for example? There's no access to router context methods.
Any news on this? I need to be able to send the user to a specific URL after they submit a form, so I can't use <Link>.
I checked react-history but it's not really what I need. Are there plans to include withRouter in v4?
I think you want to use react-history and do something like history.push ('/route');
As best as possible I try to use either the Link or Redirect component. Accessing react-history works, but could reduce the reusability of the action.
Most helpful comment
@timdorr so what's the correct way to redirect in V4 from redux-saga for example? There's no access to router context methods.