I've a react app. In a component I have a Link comp from the react-router. When I click on the link the router fires a push and a pop action? Is it normal? This way I don't know how can I solve a problem. I have a route setup like this: example/:param and when I'm on this path how can I listen properly for the param segments change?
Code:
class Example extends Component {
fetch(param) {
// ajax stuff
}
componentWillMount() {
this.fetch(this.props.param);
}
componentWillReceiveProps(nextProps) {
this.fetch(nextProps.param);
}
render() {
// render stuff
}
}
const stateToProps = (state, ownProps) => {
return {
param: ownProps.params.param,
};
};
export default connect(stateToProps, {})(Profile);
This way componentWillReceiveProps runs twice beacuse router fires push and the pop action.
Thx for any help/advice, Akos