In react-router
(esp. react-router-native
) is it possible to get a reference to History
object of the Router
from the reference of the Router
? (to be able to route from anywhere?)
Asked
Active
Viewed 278 times
0

Divyansh Goenka
- 997
- 2
- 12
- 35
-
react-router has a withRouter HOC component which exposes these props from the router context to your components: https://reacttraining.com/react-router/core/api/withRouter – Vlatko Vlahek Feb 07 '19 at 09:54
1 Answers
1
I don't think your question is clear but I will put in my thoughts. You can access history object from any component which is called inside a Route. Also, if you want to access history object in a component which is not being called in a Route, just import withRouter from react-router-dom and then return your component wrapped like this withRouter(MyComponent).

JupiterAmy
- 374
- 2
- 11