• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

386
Views
React Native: How to prevent an onLayout function from being called on every re-render

My React Native component has a prop this.props.a that gets updated every 60s elsewhere in the app. Within this component, I have a <View> with an onLayout() function. This onLayout gets called every 60s when the props are updated. Is there a way to get it to be called only the first time the component is rendered, and not on subsequent re-renders?

about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Yes! <View onLayout={()=> onLayout()}/> This part ()=>will prevent the onLayout function form being called on render.

Hope this helps! /W

about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error