With react-router
I can use the Link
element to create links which are natively handled by react router.
I see internally it calls t
To use withRouter
with a class-based component, try something like this below.
Don't forget to change the export statement to use withRouter
:
import { withRouter } from 'react-router-dom'
class YourClass extends React.Component {
yourFunction = () => {
doSomeAsyncAction(() =>
this.props.history.push('/other_location')
)
}
render() {
return (
)
}
}
export default withRouter(YourClass);