Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
Why react-router fires push and pop action when replacing path?

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

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!