-
Notifications
You must be signed in to change notification settings - Fork 24.7k
useColorScheme() returns incorrect value when app is moved to the background on iOS #49330
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
Comments
Related issue: #35972 |
Have same issues. Not happens all the time, but happens |
Hi @janoslc, I am unable to reproduce this issue with the reproducer you have provided. I am currently testing it on a simulator. Could you please confirm if reproducing it on a real device is required? Additionally, I noticed that there are no details of the New Architecture in the output of your npx react-native info. Could you please share those details as well? |
Hey @sarthak-d11
|
This is actually expected behaviour from iOS and happens on native iOS too. |
@riteshshukla04 okay, but should be flickering should not appear anyway. And it was not on bridglessMode OFF |
Maybe use something like above |
Hi, does #49431 work for you? |
Hey @riteshshukla04. I tried, unfortunately it's not a solution for me. |
@zhongwuzw how can I run it against my local setup? I tried applying the same modification as #49431 inside of |
@janoslc You can change it in |
@janoslc Hi, the screenshot is how I tested it. |
It doesn't work. To be sure I tried a couple of things:
What could be the difference between our environments? |
@artur-burlak can you please also test this modification on your project? |
It would be friendly to explain why this is closed. I understand the code works on your side, it doesn't on mine |
@janoslc Hi, the issue is auto-closed when the pr landed. The PR is reviewed by the core team. And I think maybe there has some differences that we missed. Can you have a screenshot like me to show how you applied the commit? |
@zhongwuzw Here it is: |
@janoslc Hi, Because we changed the native code, so we need to rebuild the framework. Do you know how to run using Xcode? Running using Xcode can rebuild the react native core code. |
@zhongwuzw Understood and thank you. No, I'm not familiar with building the framework. |
@janoslc @zhongwuzw Leaving a note here to confirm that the patch works as expected. I ran into the flickering issue on 0.77.1, applying this patch and rebuilding works. |
Description
useColorScheme()
call returns a momentarily incorrect value when the app is moved to the background. When bringing the app back in the foreground it causes a flashing behaviour, because all the components support dark and light theme.The issue appears on ExpoGo as well as on a physical device.
Steps to reproduce
scheme = useColorScheme()
scheme
scheme
value was changed (to dark if you were on light theme or inverse) when the app was moved to the background and changed back againReact Native Version
0.76.7
Affected Platforms
Runtime - iOS
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://snack.expo.dev/@janoslc/react-native-usecolorscheme-issue
Screenshots and Videos
The Snack in Expo Go looks like this:
ScreenRecording_02-11-2025.mp4
Having a bigger project with multiple components reduces the speed of re-rendering and it causes a flashing effect:
ScreenRecording_02-11-2025.17-13-21_1.mov
The text was updated successfully, but these errors were encountered: