0
How to use .push in react-router to navigate to external url?
I have container where i have card component. Simple code: <Card return ( title={props.title} onClick={()=>{ location.href='www.example.com' }} )/> So i need to change location.href and redirect to external link with react-router .push if i use props.navigate('www.example.com') its returning like property on localhost and redirect is not working. Can anyone help me?
3 Antworten
+ 1
I don't think you need to use .push for that.
window.location.href = "url" would do just fine.
+ 1
If I remember it correctly, all your components wrapped inside the <Route> component receives a history object as a prop. So may be props.history.push('path') shall work.
0
It is hard for testing if i use window.location.hrev. Because this is simple example of the code, but the url is changing depending on the data.map. So it is required to use .push but i dont know how to use it