Skip to content

Notify Appearance change listeners from setColorScheme - #59956

Open
lazerg wants to merge 2 commits into
react:mainfrom
lazerg:fix/appearance-set-color-scheme-change
Open

lazerg wants to merge 2 commits into
react:mainfrom
lazerg:fix/appearance-set-color-scheme-change

Conversation

@lazerg

@lazerg lazerg commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Appearance.setColorScheme() updates the cached scheme that getColorScheme() returns, but it never emits change. So useColorScheme() keeps the old scheme until the native appearanceChanged event arrives, and the same screen can show both schemes. Now setColorScheme() emits change when the scheme actually changes, and the native handler skips values that match the cache, so listeners don't get the same change twice. 'auto' still updates when the native event arrives, because the system scheme isn't known in JS yet at that point.

Fixes #59946

Changelog:

[General] [Fixed] - Appearance.setColorScheme() now notifies change listeners, so useColorScheme() updates right away

Test Plan:

Added Appearance-itest.js with a fake native module. It checks that setColorScheme('light') calls the listener once, that the native echo doesn't call it again, and that a component using useColorScheme() re-renders with light in the same task. I couldn't build the Fantom runner locally, so I checked the same cases under plain Jest: they fail on main and pass with the fix. yarn test packages/react-native/Libraries passes, and Flow, ESLint and Prettier are clean.

@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 Nov 12, 2026
@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 Nov 12, 2026

This branch has not been deployed

No deployments
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. 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.

Appearance.setColorScheme notifies no change listener, so useColorScheme() readers show the old scheme until the platform reports it

1 participant