Skip to content

feat: [Performance] Allow to pass a selector to the useWindowDimensions hook to avoid unnecessary re-renders#56989

Open
retyui wants to merge 1 commit into
facebook:mainfrom
retyui:feat/retyui/useWindowDimensions-with-selector
Open

feat: [Performance] Allow to pass a selector to the useWindowDimensions hook to avoid unnecessary re-renders#56989
retyui wants to merge 1 commit into
facebook:mainfrom
retyui:feat/retyui/useWindowDimensions-with-selector

Conversation

@retyui
Copy link
Copy Markdown
Contributor

@retyui retyui commented May 28, 2026

Summary:

Performance issue was shown on App.js 2026 Conf: https://www.youtube.com/live/4H8iRPN0Q2M?si=pykgDXJcbvi7_OIC&t=8704 by @jmeistrich

// but now with this PR devs can pass a selector 
// to subscribe to `fontScale` changes only 
const fontScale = useWindowDimensions(state => state.fontScale)
Screenshot 2026-05-28 at 18 12 22

Changelog:

[GENERAL] [ADDED] - Allow to pass a selector to useWindowDimensions(state => state.fontScale) to avoid unnecessary re-renders

Test Plan:

I did my best to cover all testcases:

yarn test packages/react-native/Libraries/Utilities/__tests__/useWindowDimensions-test.js

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 28, 2026
@github-actions
Copy link
Copy Markdown

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_BREAKING

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant