`Appearance.setColorScheme` notifies no `change` listener, so `useColorScheme()` readers show the old scheme until the platform reports it
Les mainteneurs répondent en général sous 2 jours
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 66/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- android, javascript, react-native
Piste de recherche
Read Appearance.js and useColorScheme.js, especially the setColorScheme and addChangeListener behavior described in the issue. Use the linked reproducer to observe whether calling Appearance.setColorScheme updates hook subscribers in the same commit. Done when both readers show the new scheme together and the listener behavior matches its documented contract.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Clone https://github.com/YevheniiKotyrlo/rn-set-color-scheme-no-change and connect an Android device.
- Run
bash repro.sh, which buildsReproducerApp's release APK, installs and opens it, and taps the grey area once. By hand:yarn installandyarn androidinReproducerApp, then press the grey area once. - The press calls
Appearance.setColorScheme(next)and bumps a counter in the component that rendersAppearance.getColorScheme(); its sibling rendersuseColorScheme(). After each of its commits, each component logs what the screen shows, and achangelistener 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 b9a83f3a 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
- Langage dominant
- C++
- Étoiles
- 127k
- Forks
- 25.5k
- Merge moyen
- 3 j 22 h
- PR mergées (30 j)
- 235
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de react/react-native
-
Needs: Author Feedback Needs: Repro
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
react/react-native#60059 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours
-
Needs: Triage :mag:
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
react/react-native#60000 ·
Les mainteneurs répondent en général sous 2 jours
-
`yarn test-ios` exits before building RNTester: `objc-test.sh` launches the WebSocket server script #59433 deletedPeut-être pris @lazerg l’a pris il y a 4 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
react/react-native#59939 ·
Les mainteneurs répondent en général sous 2 jours
-
iOS Fabric pointer-handler reset leaves the next lone touch non-primaryPeut-être pris @alleneubank l’a pris il y a 6 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
react/react-native#59919 ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
react/react-native#59722 ·
Les mainteneurs répondent en général sous 2 jours
Toutes les issues de react/react-native
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
petercorke/robotics-toolbox-python#943 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
area:build bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
NatronGitHub/openfx-arena#71 ·
Les mainteneurs répondent en général sous 1 jour
-
upstream-blocked
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
ROCm/FastFlowLM#1057 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
NatronGitHub/openfx-gmic#45 ·
Les mainteneurs répondent en général sous 1 jour