From 7d63235086352d8c424d634c7039551f0a5025dc Mon Sep 17 00:00:00 2001 From: Santiago <37671738+sangonz193@users.noreply.github.com> Date: Thu, 21 Nov 2024 04:43:46 -0800 Subject: [PATCH] Fix Appearance.setColorScheme(null) not resetting color scheme value (#47739) Summary: Fixes https://github.com/facebook/react-native/issues/47725 Calling Appearance.setColorScheme(null) or Appearance.setColorScheme(undefined) no longer resets the color scheme useColorScheme returns like on previous rn versions. ## Changelog: [GENERAL] [FIXED] - Fix `Appearance.setColorScheme(null)` not resetting color scheme value Pull Request resolved: https://github.com/facebook/react-native/pull/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 --- packages/react-native/Libraries/Utilities/Appearance.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react-native/Libraries/Utilities/Appearance.js b/packages/react-native/Libraries/Utilities/Appearance.js index 3cd23a65fe2245..d96047b1dda5f2 100644 --- a/packages/react-native/Libraries/Utilities/Appearance.js +++ b/packages/react-native/Libraries/Utilities/Appearance.js @@ -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()), + }; } }