Skip to content

React Compilerを導入 - #6095

Merged
TinyKitten merged 6 commits into
devfrom
feature/react-compiler
Jun 1, 2026
Merged

TinyKitten merged 6 commits into
devfrom
feature/react-compiler

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jun 1, 2026 •

Copy link
Copy Markdown
Member

概要

React Compiler を導入し、導入に伴って StrictMode 下で露出した副作用の不具合を修正します。

変更の種類

  • バグ修正
  • 新機能
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

  • app.config.ts で React Compiler を有効化しました。
  • StrictMode 適用範囲を整理し、アプリ本体の StrictMode 検査を維持しつつ PortalProvider 由来の重複影響を避ける構成にしました。
  • Main 画面の状態リセットを mount cleanup ではなく navigation の beforeRemove に寄せ、StrictMode の開発時 cleanup で駅数が 0 になる問題を防ぎました。
  • effect 起点の自動 Alert.alert が StrictMode で二重表示されないよう、表示中キーで抑止する showAlertWhilePresenting を追加しました。
  • ウォークスルーを通常ツリー内で表示し、Native Alert より前面に重ならないようにしました。あわせて measureInWindow() 由来の画面座標をオーバーレイのローカル座標へ補正し、スポットライト位置のずれを修正しました。
  • StrictMode 下の React Native 副作用、特に自動 Alert の扱いを AGENTS.md に明文化しました。

テスト

  • npm run lint が通ること
  • npm test が通ること
  • npm run typecheck が通ること

追加で以下の対象 Jest が通ることを確認しました。

set TZ=UTC&& npx jest --runInBand src/utils/alertPresentation.test.ts src/hooks/useInitialNearbyStation.test.tsx src/hooks/useResetMainState.test.ts src/components/LineBoard.test.tsx src/hooks/useWalkthroughCompleted.test.tsx src/hooks/useSelectLineWalkthrough.test.tsx src/screens/SelectLineScreen.render.test.tsx

npm test 全体は未実行です。

関連Issue

スクリーンショット(任意)

@coderabbitai

coderabbitai Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

React StrictMode環境下でのAlert.alert重複表示問題を解決するため、同一キーの表示抑止ユーティリティshowAlertWhilePresentingを新規実装。プロジェクト全体のAlert.alert呼び出しをこのユーティリティに置き換え統一。WalkthroughOverlayのPortal廃止と位置補正、React Compiler実験設定有効化、ガイドドキュメント追加も実施。

Changes

StrictMode下でのAlert表示統一

Layer / File(s) Summary
showAlertWhilePresentingユーティリティ実装
src/utils/alertPresentation.ts, src/utils/alertPresentation.test.ts
表示中キーをSet<string>で管理し、同一キーのアラート重複表示を防ぐヘルパー関数を実装。ボタン押下とonDismissで確実にキーを解放するtry/finally構造。Jest テストで重複表示抑止・再表示・onDismiss後の再表示を検証。
Hookでのアラート置き換え
src/hooks/useCheckStoreVersion.ts, src/hooks/useInitialNearbyStation.ts, src/hooks/useInitialNearbyStation.test.tsx
useCheckStoreVersionとuseInitialNearbyStation内のAlert.alert呼び出しをshowAlertWhilePresentingに置き換え。AsyncStorage連携やボタンコールバック処理もラッパー経由に統一。テスト引数検証を拡張して onDismiss コールバック確認。
ProviderとAppStartupのアラート置き換え
src/providers/DeepLinkProvider.tsx, src/index.tsx
DeepLinkProviderのエラー表示とindex.tsxのフォント読み込みエラー通知をshowAlertWhilePresentingに統一。index.tsxでは AppContent コンポーネントを分離し、ナビゲーション条件分岐(Privacy/MainStack/TuningSettings)を移行。StrictMode をAppContent直下に配置。
MainScreenのアラート置き換えとライフサイクル更新
src/screens/Main.tsx
地下鉄・休日・平日・一部通過注意、常時許可未付与、Doze確認のアラート6つをshowAlertWhilePresentingに置き換え。useNavigation と beforeRemove イベントリスナーで resetMainState ライフサイクルを変更。
WalkthroughOverlayのPortal廃止と位置補正
src/components/WalkthroughOverlay.tsx
Portal経由から通常ツリー内描画へ移行。overlayRef と measureInWindow() でローカル座標測定し、spotlightArea を adjustedSpotlightArea に補正。マスク描画とツールチップY計算の統一基準に採用。
設定・ドキュメント更新
app.config.ts, AGENTS.md
app.config.ts で experiments: { reactCompiler: true } を設定。AGENTS.md に「React Native side effects under StrictMode」ガイド節を追加し、useEffect副作用・Alert呼び出し・ガード・ライフサイクル注意点を箇条書き明記。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Alert の声、二重に響かず
StrictMode の鏡、ひとつに映して
Overlay も整い、Config も整い
走り続けよ、よきアプリよ
ガイドに従え、副作用よ ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PRのタイトルは「React Compilerを導入」で、app.config.tsでReact Compilerを有効化する変更を反映していますが、StrictMode下での副作用修正という同等に重要な変更を含んでいません。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed PR説明は要件テンプレートに従い、概要、変更の種類、変更内容、テスト確認、関連Issue、スクリーンショットの各セクションを完備している。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/react-compiler

Comment @coderabbitai help to get the list of available commands and usage tips.

@TinyKitten TinyKitten self-assigned this Jun 1, 2026
@github-actions github-actions Bot added the react label Jun 1, 2026
@TinyKitten
TinyKitten marked this pull request as ready for review June 1, 2026 23:06

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/components/WalkthroughOverlay.tsx (1)

190-197: ⚡ Quick win

アニメーションのクリーンアップを追加してください。

StrictMode 下では useEffect が再実行されるため、前のアニメーションを停止しないと重複実行される可能性があります。

♻️ 修正案
   useEffect(() => {
     const targetY = calculateTooltipY();
-    RNAnimated.timing(animatedY, {
+    const animation = RNAnimated.timing(animatedY, {
       toValue: targetY,
       duration: ANIMATION_DURATION,
       useNativeDriver: false,
-    }).start();
+    });
+    animation.start();
+    return () => animation.stop();
   }, [currentStepIndex, adjustedSpotlightArea?.y, screenHeight]);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/WalkthroughOverlay.tsx` around lines 190 - 197, The effect
that animates animatedY (inside the WalkthroughOverlay component) can re-run
under StrictMode and must stop previous animations; capture the
RNAnimated.timing(...) return value into a variable (e.g., animation), call
animation.start() as now, and return a cleanup function that calls
animation.stop() (or animation.stopAnimation()) so previous animations are
cancelled when the effect re-runs or component unmounts; keep the same
dependency array ([currentStepIndex, adjustedSpotlightArea?.y, screenHeight]).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/screens/Main.tsx`:
- Around line 465-467: The current listener-only approach
(navigation.addListener('beforeRemove', resetMainState) inside the useEffect)
can miss cases where MainStack is removed by parent conditional rendering (e.g.
isUnderMaintenance / isInternetAvailable), so ensure resetMainState (from
useResetMainState.ts which resets navigationState and stationState) also runs on
component unmount and when those parent conditions change: update the useEffect
to return a cleanup that calls resetMainState (so it runs on unmount) and/or add
another effect that watches the parent condition flags (isUnderMaintenance,
isInternetAvailable) and invokes resetMainState when they transition to a state
that will unmount or replace the stack.

---

Nitpick comments:
In `@src/components/WalkthroughOverlay.tsx`:
- Around line 190-197: The effect that animates animatedY (inside the
WalkthroughOverlay component) can re-run under StrictMode and must stop previous
animations; capture the RNAnimated.timing(...) return value into a variable
(e.g., animation), call animation.start() as now, and return a cleanup function
that calls animation.stop() (or animation.stopAnimation()) so previous
animations are cancelled when the effect re-runs or component unmounts; keep the
same dependency array ([currentStepIndex, adjustedSpotlightArea?.y,
screenHeight]).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3e795657-8db9-405c-be11-69c28d8b21c3

📥 Commits

Reviewing files that changed from the base of the PR and between 795c856 and 2528da6.

📒 Files selected for processing (11)
  • AGENTS.md
  • app.config.ts
  • src/components/WalkthroughOverlay.tsx
  • src/hooks/useCheckStoreVersion.ts
  • src/hooks/useInitialNearbyStation.test.tsx
  • src/hooks/useInitialNearbyStation.ts
  • src/index.tsx
  • src/providers/DeepLinkProvider.tsx
  • src/screens/Main.tsx
  • src/utils/alertPresentation.test.ts
  • src/utils/alertPresentation.ts

Comment thread src/screens/Main.tsx Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant