-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Appearance.getColorScheme() return wrong color schema for when call first time only in ios #36713
Comments
|
I can confirm that this is happening on RN 0.71.7 and according to changelog it's not fixed in 0.71.8 either. |
It happens on RN 0.72.0 too |
Summary: Closes facebook#35972 Closes facebook#36713 This PR addresses a couple of issues with `useColorScheme` and the `Appearance` API. - facebook#38214 introduced a regression. Using to `RCTExecuteOnMainQueue` was a mistake as we need this to happen synchronously to return the result. Doing it async causes the `traitCollection` to remain uninitialized. - The `useColorScheme` hook is updating when the app is in the background on iOS and the OS is taking the snapshots for the app switcher. This causes a flash when returning to the app as the correct color is set again. Here, we can check for the app state in `traitCollectionDidChange` and not send these events when in the background. - Removed a line that was left over after some OS version checks were removed when support for iOS 12 was dropped. ## Changelog: [IOS] [FIXED] - Don't send the `RCTUserInterfaceStyleDidChangeNotification` when the app is in the background. Pull Request resolved: facebook#39439 Test Plan: Tested on `rn-tester`, logged the changes whenever `useColorScheme` updates. It no longer happens when the app is in the background. The returned interface style on the initial render is always correct now. Reviewed By: NickGerleman Differential Revision: D49454281 Pulled By: javache fbshipit-source-id: 87e24158a49c50608c79e73fb484442f5aad36a6
Happens to me after upgrading to RN version 0.74 |
Happening for me as well: only on first start (after fresh install of the app) |
Updating react-native from 71.6 to 74.0, now 74.0 causes useColorScheme() and Appearance.getColorScheme() to always be 'light' when app first loads. Output of npx react-native info |
Description
Appearance.getColorScheme() rerturn wrong color schema when app come from background to foreground mode everytime.
apperance.issue.mp4
React Native Version
0.70.6
Output of
npx react-native info
System:
OS: macOS 13.1
CPU: (8) x64 Intel(R) Core(TM) i5-1030NG7 CPU @ 1.10GHz
Memory: 98.94 MB / 8.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.16.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 8.11.0 - /usr/local/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.10.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
Android SDK: Not Found
IDEs:
Android Studio: 2021.3 AI-213.7172.25.2113.9123335
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
Languages:
Java: 11.0.16.1 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.1.0 => 18.1.0
react-native: 0.70.6 => 0.70.6
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
Steps to reproduce
minimize the app from background to foreground.
Snack, code example, screenshot, or link to a repository
The text was updated successfully, but these errors were encountered: