question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React-native Appearance has some issue on background mode. Here is an video example how to reproduce the bug in the app https://ru.files.fm/u/x5uzfjqtb#/view/swr72wr5p

Appearance listener will change the colorScheme value to “light” when app is in background mode and never back to dark.

useEffect(() => {
    const listener = ({colorScheme}: any) => {
      setIsDarkMode(colorScheme === 'dark');
    };
    Appearance.addChangeListener(listener);

    return () => {
      Appearance.removeChangeListener(listener);
    };
  }, []);

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:7
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ouabingcommented, May 10, 2021

Same issue like what @1111mp described. Appearance.addChangeListener will receive a wrong theme when app goes back to foreground.

react-native: 0.64.1

1reaction
1111mpcommented, May 5, 2021

I also encountered the same problem.

React.useEffect(() => {
    const _subscription = ({colorScheme}: Appearance.AppearancePreferences) => {
      console.log(colorScheme);
      console.log(Appearance.getColorScheme());
      stores.userStore.setAppTheme(colorScheme!);
    };

    Appearance.addChangeListener(_subscription);

    return () => {
      Appearance.removeChangeListener(_subscription);
    };
  }, []);

The phone is set to dark mode. When my app switches to the background, it will trigger a listener.The colorScheme parameter of the listener method prints light, while the one obtained by Appearance.getColorScheme() is dark. https://user-images.githubusercontent.com/31227919/117095257-771dad80-ad98-11eb-97d8-929b15d8f611.mov

Read more comments on GitHub >

github_iconTop Results From Across the Web

Body dysmorphic disorder - Symptoms and causes - Mayo Clinic
This mental disorder causes persistent, intense focus, shame and anxiety over perceived body defects, often resulting in many cosmetic procedures as a fix....
Read more >
Appearance Concerns - Centre for Clinical Interventions
It is normal to feel dissatisfied with your appearance from time to time. However, if you are too concerned about your appearance it...
Read more >
Nursing staff's experience of appearance issues in various ...
Healthcare providers meet patients with a wide range of appearance concerns, such as different disfiguring conditions, disabilities, ...
Read more >
How Physical Appearance Issues lead to Teen Depression
A study has established that adolescents who have negative concerns about their body image can more easily be affected by teen depression.
Read more >
Body Dissatisfaction, Importance of Appearance, and ... - NCBI
Besides negative body evaluation and the importance of appearance, ... has emerged as a central issue for boys and men (e.g. 35–38).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found