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.

Root userInterfaceStyle does not apply on Android in Expo Go

See original GitHub issue

Summary

{
  "expo": {
    "userInterfaceStyle": "automatic",
  }
}

this will not change the user interface style behavior to allow for both light and dark themes, instead you need to set it on the Android key

{
  "expo": {
    "userInterfaceStyle": "automatic",
    "android": {
      "userInterfaceStyle": "automatic"
    }
  }
}

The root key does work as expected on iOS

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

Android

SDK Version (managed workflow only)

42

Environment

  Expo CLI 4.7.2 environment info:
    System:
      OS: macOS 11.2.3
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 14.15.2 - ~/.nvm/versions/node/v14.15.2/bin/node
      Yarn: 1.22.10 - /usr/local/bin/yarn
      npm: 6.14.13 - ~/.nvm/versions/node/v14.15.2/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    Managers:
      CocoaPods: 1.10.1 - /usr/local/bin/pod
    SDKs:
      iOS SDK:
        Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
      Android SDK:
        API Levels: 26, 28, 29, 30
        Build Tools: 26.0.3, 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3
        System Images: android-26 | Google APIs Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom
        Android NDK: 21.0.6113669
    IDEs:
      Android Studio: 4.1 AI-201.8743.12.41.7042882
      Xcode: 12.5/12E262 - /usr/bin/xcodebuild
    npmPackages:
      expo: ~42.0.0 => 42.0.0
      react: 16.13.1 => 16.13.1
      react-dom: 16.13.1 => 16.13.1
      react-native: https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz => 0.63.2
      react-native-web: ~0.13.12 => 0.13.18
    npmGlobalPackages:
      expo-cli: 4.7.2
    Expo Workflow: managed

Reproducible demo or steps to reproduce from a blank project

https://github.com/brentvatne/schemes

Run the project on Android and toggle between light/dark themes, notice the text doesn’t update. Now add "userInterfaceStyle": "automatic" under the "android" key and reload the app (not just fast refresh, full reload) and notice it works as expected.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
brentvatnecommented, Aug 14, 2021

this fix will land in sdk 43

2reactions
umrashrfcommented, Oct 7, 2021

Always returns light on iPhone simulator and always returns dark on actual iPhone device.

"dependencies": {
  "@expo/metro-config": "^0.1.84",
  "@expo/vector-icons": "^12.0.0",
  "@react-navigation/drawer": "^6.1.4",
  "@react-navigation/native": "^6.0.2",
  "@react-navigation/native-stack": "^6.1.0",
  "babel-preset-expo": "8.3.0",
  "expo": "~42.0.1",
  "expo-constants": "~11.0.1",
  "expo-font": "~9.2.1",
  "expo-image-picker": "~10.2.2",
  "expo-location": "~12.1.2",
  "expo-splash-screen": "~0.11.2",
  "expo-status-bar": "~1.0.4",
  "expo-updates": "~0.8.2",
  "react": "16.13.1",
  "react-dom": "16.13.1",
  "react-native": "0.63.4",
  "react-native-codegen": "^0.0.7",
  "react-native-elements": "^3.4.2",
  "react-native-gesture-handler": "~1.10.2",
  "react-native-reanimated": "~2.2.0",
  "react-native-safe-area-context": "3.2.0",
  "react-native-safe-area-view": "^1.1.1",
  "react-native-screens": "~3.4.0",
  "react-native-unimodules": "~0.14.5",
  "react-native-web": "~0.13.12"
}

app.json

"expo": {
    "name": "Example",
    "slug": "example",
    "version": "1.0.0",
    "assetBundlePatterns": [
      "**/*"
    ],
    "userInterfaceStyle": "automatic",
    "ios": {
      "bundleIdentifier": "dev.expo.Example",
      "userInterfaceStyle": "automatic",
      "infoPlist": {
        "UIUserInterfaceStyle": "Automatic"
      }
    }
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native Expo. Android dark mode issue - Stack Overflow
I have found a solution for React Native without Expo: React native android dark mode issue but I cannot use it because I...
Read more >
Light and dark modes - Expo Documentation
Light and dark modes. Learn how to support light and dark modes in your app. Regardless of whether you are personally on team...
Read more >
React-native-appearance - npm.io
Access operating system appearance information on iOS, Android, and web. Currently supports detecting preferred color scheme (light/dark). Installation.
Read more >
Vaibhav Gadekar on Twitter: "I have created spotify ui clone with ...
... from live api server with realtime songs using react native and expo ... Root userInterfaceStyle does not apply on Android in Expo...
Read more >
invariant violation: "main" has not been registered. this can ...
The project loads on my android device and it was loading on my ios device but for ... If you're trying to use...
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