Skip to content

Appearance.setColorScheme notifies no change listener, so useColorScheme() readers show the old scheme until the platform reports it #59946

Open

Description

@YevheniiKotyrlo

Description

Appearance.setColorScheme(scheme) sets the value Appearance.getColorScheme() returns at once and emits no change. useColorScheme() subscribes through addChangeListener, so a component that reads it keeps the old scheme until the native module reports appearanceChanged, while a component that re-renders for another reason in the same press already reads the new one, and one commit shows both schemes. addChangeListener's doc says its listener hears "a call to setColorScheme()" (Appearance.js).

Steps to reproduce

  1. Clone https://github.com/YevheniiKotyrlo/rn-set-color-scheme-no-change and connect an Android device.
  2. Run bash repro.sh, which builds ReproducerApp's release APK, installs and opens it, and taps the grey area once. By hand: yarn install and yarn android in ReproducerApp, then press the grey area once.
  3. The press calls Appearance.setColorScheme(next) and bumps a counter in the component that renders Appearance.getColorScheme(); its sibling renders useColorScheme(). After each of its commits, each component logs what the screen shows, and a change listener logs when it runs.

Expected: the commit the press makes shows the new scheme in both components.

Actual: that commit shows useColorScheme() dark beside Appearance.getColorScheme() light, and the useColorScheme() reader catches up only after the change listener runs.

React Native Version

0.88.1

Appearance.js and useColorScheme.js on main at b9a83f3 are the same files as in 0.88.1.

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info

System:
  OS: Windows 11 10.0.26300
  CPU: "(32) x64 AMD Ryzen 9 9950X3D 16-Core Processor          "
  Memory: 128.21 GB / 255.67 GB
Binaries:
  Node:
    version: 26.12.1
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.22
    path: C:\Users\…\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 12.2.1
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowDevelopmentWithoutDevLicense: Enabled
    Versions:
      - 10.0.19041.0
      - 10.0.26100.0
IDEs:
  Android Studio: AI-262.9437.185.2621.16467767
  Visual Studio: Not Found
Languages:
  Java:
    version: 17.0.20.1
    path: C:\Program Files\Microsoft\jdk-17.0.20.101-hotspot\bin\javac.EXE
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 20.2.0
    wanted: 20.2.0
  react:
    installed: 19.3.0
    wanted: 19.3.0
  react-native:
    installed: 0.88.1
    wanted: 0.88.1
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

react-native 0.88.1, release build, SM-S911B, Android 14
the Appearance.getColorScheme() reader committed: the screen shows useColorScheme() dark and Appearance.getColorScheme() dark (agree)
ready
press 1: Appearance.setColorScheme('light') and a state update
the Appearance.getColorScheme() reader committed: the screen shows useColorScheme() dark and Appearance.getColorScheme() light (DISAGREE)
change listener: light, 2 ms after the press
the useColorScheme() reader committed: the screen shows useColorScheme() light and Appearance.getColorScheme() light (agree)
RESULT: defect shows: after Appearance.setColorScheme a commit shows useColorScheme() and Appearance.getColorScheme() disagreeing, until the change listener runs

MANDATORY Reproducer

https://github.com/YevheniiKotyrlo/rn-set-color-scheme-no-change

Activity

  1. dhairyajangir commented on Nov 11, 2026

    @dhairyajangir

    Thanks for the detailed report. I inspected Appearance.js on main and ran a source-level simulation with a fake native module: after setColorScheme('light'), getColorScheme() returned light but the change listener ran only after a simulated native event. This was not an Android or React-renderer test.

    Are you already working on a fix, or would you welcome a contribution? OpenAI Codex assisted with the source inspection and simulation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions