react / react/react-native

[0.83.1] useColorScheme returns unspecified when state updates

オープン
#54,959 コメント 4 件 リアクション 5 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Needs: Triage :mag:
主要言語
C++
スター
127k
フォーク
25.3k
平均マージ
1日 23時間
マージ済み PR(30日)
4

説明

Description

I’m using useColorScheme to manage theming in my app.

The app has three theme options: System, Dark, and Light.

  • When System is selected, I call Appearance.setColorScheme('unspecified').
  • When Dark is selected, I call Appearance.setColorScheme('dark').
  • When Light is selected, I call Appearance.setColorScheme('light').

If the system theme is dark and I call Appearance.setColorScheme('unspecified'), useColorScheme correctly returns dark.

However, if I update a state during the same button click, useColorScheme starts returning unspecified instead.

Steps to reproduce
  1. Change color schemes by clicking buttons
  2. It should work
  3. Enable state change by clicking enable state change button
  4. Change color schemes by clicking buttons
  5. It returns unspecified when you change from system color (dark or light) to system
React Native Version

0.83.1

Affected Platforms

Runtime - iOS

Output of npx @react-native-community/cli info
System:
  OS: macOS 26.2
  CPU: (8) arm64 Apple M1 Pro
  Memory: 108.17 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.19.0
    path: /Users/aykutsaki/.nvm/versions/node/v22.19.0/bin/node
  Yarn:
    version: 1.22.15
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.9.3
    path: /Users/aykutsaki/.nvm/versions/node/v22.19.0/bin/npm
  Watchman:
    version: 2025.05.26.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.2
      - iOS 26.2
      - macOS 26.2
      - tvOS 26.2
      - visionOS 26.2
      - watchOS 26.2
  Android SDK:
    API Levels:
      - "31"
      - "35"
      - "36"
    Build Tools:
      - 35.0.0
      - 36.0.0
    System Images:
      - android-35 | Google Play ARM 64 v8a
      - android-36 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2025.2 AI-252.25557.131.2521.14344949
  Xcode:
    version: 26.2/17C52
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /Users/aykutsaki/.jenv/shims/javac
  Ruby:
    version: 3.2.2
    path: /Users/aykutsaki/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.0.0
    wanted: 20.0.0
  react:
    installed: 19.2.0
    wanted: 19.2.0
  react-native:
    installed: 0.83.1
    wanted: 0.83.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
Stacktrace or Logs
No crash
MANDATORY Reproducer

https://github.com/AuroPick/color-scheme-unspecified

Screenshots and Videos

https://github.com/user-attachments/assets/78519563-4a32-44c0-8bf3-2a997bff4f57

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、iOS で https://github.com/AuroPick/color-scheme-unspecified の必須の再現手順を実行し、Appearance.setColorScheme と併せて useColorScheme を確認します。状態更新の経路を追跡し、System を再度選択したときに unspecified ではなく解決済みのシステムテーマが報告されることを、同じボタンクリックで別の状態も変化する場合を含めて検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
react-native
領域
mobile
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。