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

281
Views
React Native: shouldComponentUpdate() not preventing render() from being called

I have a React Native component where I want to prevent the render() method from being called.

class A extends Component {
  shouldComponentUpdate() {
    return false;
  }
  render() {
    return(...)
  }
}

Returning false in shouldComponentUpdate should prevent render() from being called, but it doesn't. Is there something I'm doing wrong?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Indeed, it prevents a rerender but not the initial rendering. This is documented here.

Use shouldComponentUpdate() to let React know if a component’s output is not affected by the current change in state or props. The default behavior is to re-render on every state change, and in the vast majority of cases you should rely on the default behavior.

and

shouldComponentUpdate() is invoked before rendering when new props or state are being received. Defaults to true. This method is not called for the initial render or when forceUpdate() is used.

Hence, if you return false, then you only prevent a rerendering on state changes.

about 4 years ago · Juan Pablo Isaza Report

0

you can try use hooks useMemo or useCallback https://reactjs.org/docs/hooks-reference.html to choose what you want to update

about 4 years ago · Juan Pablo Isaza Report
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!