Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Application always in light mode on initial load. (#44335)
Summary: Hi, I'm Filip from software mansion. This PR solves a problem I stumbled upon. On iOS, applications are always in light mode on initial load. Even if the device is turned to dark mode. ### Cause of the problem: The initial appearance is taken from `RCTKeyWindow()`, but at the time of initialization of `RCTAppearance` it does not exist yet. ### Solution: This PR moves repeats initialization of the appearance the first time `getColorScheme()` is called if it was not initialized properly before. ## Changelog: [IOS] [FIXED] - Fix dark mode on initial load. Pull Request resolved: #44335 Test Plan: - Create new React native app with `npx react-native@latest init AwesomeProjec` - Run the application on iphone using simulator - turn on dark mode using `cmd+shift+A` - close application and run it again ### without changes: The application will turn on in light mode despite the simulator being set to dark mode. When you reload the application it works as expected (is in dark mode) ### with changes: Works as expected #### note: any change to device ui settings will trigger a listener that will set appearance to correct state, so testing of this problem should happen in as isolated conditions as possible. Reviewed By: cortinico Differential Revision: D58189058 Pulled By: cipolleschi fbshipit-source-id: 9a864f3d045e966bc88601f661d221c4796c5c95
- Loading branch information