Reputation: 1533
I'm trying to follow the react-router tutorial here trying to navigate using a child route and it doesn't work.
For example given this route definition:
export default <Route path="wifi" component={ Wifi }>
<IndexRoute component={WifiView}/>
<Route path="list" component= {WifiListView}/>
<Route path="connect" component={WifiConnectView}/>
</Route>;
If we are on "/"
and navigate to "/wifi"
we are good. The WifiView
is presented however if if from "/wifi"
we call hasHistory.push('list')
it doesn't find the route. I would assume that the route is relative to its current location since I'm not using the "/"
but that isn't being respected.
Also the document said:
You can also use the router that Router provides on "context". First, you ask for context in the component, and then you can use it...
But I don't see anything that mentions how to do that in TypeScript so I'm using the static hashHistory
.
It looks like novice questions but I had nowhere to ask since the suggested Discord channels are all dead... Can anyone help with those?
Thanks! Appreciate any help!
Upvotes: 0
Views: 248
Reputation: 1533
Ok finally found the replies to my questions...
hasHistory.push('list')
doesn't work.context.router
we need to use withRouter
high order component but that isn't exposed on the TypeScript definition files they provide.Upvotes: 1