asBaseComponent: stale module-level colorScheme prevents re-render on scheme switch back
メンテナーはふだん 1 日以内に返信
@huytdps13400 がすでに取り組んでいます。
2026年10月4日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 85/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- javascript, react-native
- 領域
- frontend, mobile-dev
調査の方向性
src/commons/asBaseComponent.js から始め、BaseComponent が colorScheme state をどのように初期化し、appearanceListener を登録するかを確認します。最初の変更後にマウントされたコンポーネントを含めて、light-to-dark-to-light の切り替えシーケンスを再現します。影響を受ける RNUI コンポーネントが両方向で正しく再レンダリングされ、古い色を保持しなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
Description
asBaseComponent HOC captures colorScheme as a module-level constant at import time. Since BaseComponent extends React.PureComponent (via UIComponent), components mounted after a scheme change hold a stale state.colorScheme that matches the original scheme. When switching back to that original scheme, the appearanceListener guard (this.state.colorScheme !== colorScheme) evaluates to false, skipping setState and preventing re-render.
Related to
- Components
- Demo
- Docs
- Typings
Steps to reproduce
- App starts in light mode → module-level
colorSchemeis captured as'light' - Go to a settings/appearance screen and switch to dark mode → all RNUI components re-render correctly
- Navigate to any screen — new components mount during dark mode with
state.colorScheme = 'light'(stale module-level value) - Switch back to light mode →
Scheme.broadcastSchemeChange('light')fires - Stale components check
'light' !== 'light'→false→setStateis never called → no re-render
Expected behavior
All RNUI components (Text, View, Button, Switch, etc.) should re-render with the updated color scheme when switching in both directions (light → dark AND dark → light).
Actual behavior
Components mounted after the first scheme change do not re-render when switching back to the original scheme. They retain the previous scheme's colors (e.g., light gray text on a light background) because BaseComponent (a PureComponent) skips rendering — both props and state appear unchanged.
More Info
Code snippet
The bug is in src/commons/asBaseComponent.js:
// Line 8 — evaluated ONCE at module load, never updated
const colorScheme = Scheme.getSchemeType();
function asBaseComponent(WrappedComponent, options = {}) {
// BaseComponent extends UIComponent which extends React.PureComponent
class BaseComponent extends UIComponent {
state = {
error: false,
colorScheme // All instances get the stale module-level value
};
appearanceListener = colorScheme => {
// This guard fails for stale instances when switching back to the original scheme
if (this.state.colorScheme !== colorScheme) {
this.setState({ colorScheme });
}
};
}
}
Fix — evaluate Scheme.getSchemeType() per instance instead of once at module level:
const EMPTY_MODIFIERS = {};
-const colorScheme = Scheme.getSchemeType();
function asBaseComponent(WrappedComponent, options = {}) {
class BaseComponent extends UIComponent {
state = {
error: false,
- colorScheme
+ colorScheme: Scheme.getSchemeType()
};
Screenshots/Video
N/A — the visual symptom is dark-theme text colors (e.g., #C9D6DF) rendered on a light-theme background (#F0F5F9), causing text to blend/disappear.
Environment
- React Native version: 0.83
- React Native UI Lib version: 8.3.4
Affected platforms
- Android
- iOS
- Web
- 主要言語
- TypeScript
- スター
- 7.2k
- フォーク
- 749
- 平均マージ
- 29分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
wix/react-native-ui-lib のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
wix/react-native-ui-lib#4022 ·
メンテナーはふだん 1 日以内に返信
-
SortableGridList does not forward props to its inner ScrollView (inconsistent with SortableList)対応中かも @yinminqian が 173 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
wix/react-native-ui-lib#4002 ·
メンテナーはふだん 1 日以内に返信
-
RN 0.85.0 StyleSheet.absoluteFillObject is removed対応中かも @ChrisJamesC が 79 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
wix/react-native-ui-lib#3965 · コメント 3 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
wix/react-native-ui-lib#4044 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
wix/react-native-ui-lib#4043 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
wix/react-native-ui-lib の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Yeraze/meshmonitor#6239 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
better-auth/better-auth#12292 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
The sample email preview's ResizeObserver is never disconnected and keeps raising errors after leaving Settings対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
area:ui bug effort:S priority:P2
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
Typo in WSL project description on Projects page対応中かも @akhil9tiet が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
microsoft/opensource.microsoft.com#1066 · コメント 1 件 ·