Skip to content

Commit

Permalink
Fix Appearance.setColorScheme(null) not resetting color scheme value (#…
Browse files Browse the repository at this point in the history
…47739)

Summary:
Fixes #47725

Calling Appearance.setColorScheme(null) or Appearance.setColorScheme(undefined) no longer resets the color scheme useColorScheme returns like on previous rn versions.

## 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] [FIXED] - Fix `Appearance.setColorScheme(null)` not resetting color scheme value

Pull Request resolved: #47739

Test Plan: Repo with a patch ready to test: https://github.com/sangonz193/react-native-color-scheme-patch

Reviewed By: yungsters

Differential Revision: D66230236

Pulled By: cipolleschi

fbshipit-source-id: cc668acb1fde6d30f2706fc0ab7dee5cea1c3b14
  • Loading branch information
sangonz193 authored and facebook-github-bot committed Nov 21, 2024
1 parent 9f604db commit 7d63235
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/react-native/Libraries/Utilities/Appearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ export function setColorScheme(colorScheme: ?ColorSchemeName): void {
const {NativeAppearance} = state;
if (NativeAppearance != null) {
NativeAppearance.setColorScheme(colorScheme ?? 'unspecified');
state.appearance = {colorScheme};
state.appearance = {
colorScheme: toColorScheme(NativeAppearance.getColorScheme()),
};
}
}

Expand Down

0 comments on commit 7d63235

Please sign in to comment.