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

127
Views
Need some clarification on getDerivedStateFromProps when reacting to toggling props

In the case below, where I need to update the state if some mode was enabled, is there any performance implication of unconditionally copying props.isScaffoldingMode to the state?

I wonder, if I should use didUpdate for this case or copy the prop only when it changes.

I am unsure if getDerivedStateFromProps causes a full re-render, like setting the state in didUpdate would in this case.

Thank you for your time.

  static getDerivedStateFromProps(nextProps, prevState) {
    let newState = { prevIsScaffoldingMode: nextProps.isScaffoldingMode };
   
    if (nextProps.isScaffoldingMode && !prevState.prevIsScaffoldingMode) {
      const scaffoldingState = StandardItemComponent.prepareScaffoldingMode(nextProps);
      newState = { ...newState, ...scaffoldingState };
    }
      return newState;
    }
about 4 years ago · Juan Pablo Isaza
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!