SIGN IN SIGN UP
facebook / react-native UNCLAIMED

A framework for building native applications using React

0 0 0 C++

Minor Performance and Code Quality Improvements ✈️ (#50682)

Summary:
*Hi,*

I made a small update to the dependency array in `useLayoutEffect`, changing it from `[native]` to `[native.value]` for better precision. Since JavaScript compares objects by reference, this change can lead to a minor performance improvement. Additionally, as `useLayoutEffect` is render-blocking, I wanted to ensure we optimize its usage as much as possible.

As a micro-optimization and in line with good coding practices, I also changed a `let + if` variable to `const`. While the performance gain is minimal, it contributes to cleaner and more consistent code.

Please feel free to review, and I sincerely apologize if I made any mistakes in the process.

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
*[General] [Changed]* – Refined `useLayoutEffect` dependency array from `[native]` to `[native.value]` for improved precision and efficiency in re-renders.
*[General] [Changed]* – Replaced `let` with `const` where applicable for better code standards and micro-optimization.

Pull Request resolved: https://github.com/facebook/react-native/pull/50682

Reviewed By: huntie

Differential Revision: D72979663

Pulled By: yungsters

fbshipit-source-id: 64ac09811b78ca67be903d8cd91da8cd6f0a45fa
S
Sanjaiyan Parthipan committed
38fefb2771d7ff65568fa989f2ca4a5bf44e58ec
Parent: be24707
Committed by Facebook GitHub Bot <[email protected]> on 4/15/2025, 4:17:02 PM