if I'm on a movie page
/movie/some-movie
and go on link to
/movie/another-movie
component not render
react-route v4
router
<Route exact path="/movie/:urlRusLat" component={Movie} />
link
<Link to={'/' + item.media_type + '/' + urlRusLat(item.title || item.name) + '-' + item.id} className="result-element" key={index}>
I try use componentWillReceiveProps and send request, but i receive in props new location, like in nextProps.
componentWillReceiveProps(nextProps) {
console.log(this.props)
if (this.props.location.pathname !== nextProps.location.pathname) {
this.sendRequest();
}
}
componentDidMount() {
this.sendRequest();
}
componentWillUnmount() {
this.props.clearMovieData();
}
sendRequest = () => {
let movieId = this.props.location.pathname.split('-');
this.props.loadMovieData(movieId[1]);
}
How can i make send request if path change, or render component again?