Skip to content

StrictModeでPortal経由のモーダルが表示されない問題を修正 - #6109

Merged
TinyKitten merged 1 commit into
devfrom
fix/portal-strictmode-modal-not-shown
Jun 3, 2026
Merged

TinyKitten merged 1 commit into
devfrom
fix/portal-strictmode-modal-not-shown

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jun 3, 2026 •

Copy link
Copy Markdown
Member

概要

React Compiler 導入(#6095)でルートに <StrictMode> を追加して以降、開発ビルドで長押しメニューの「設定」など Portal 経由のモーダルが表示されなくなっていた問題を、@gorhom/portal への patch-package パッチで修正します。

変更の種類

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

変更内容

  • patches/@gorhom+portal+1.0.14.patch を追加。
  • @gorhom/[email protected] の Portal コンポーネントは mount effect の cleanup で handleOnMountRef / handleOnUnmountRef / handleOnUpdateRef を undefined に潰していた。
  • StrictMode(React 19)は初回マウントを mount → unmount → remount でシミュレートするため、unmount で ref が破棄され、remount 時の handleOnMountRef.current?.() が no-op 化 → Portal がホストへ再登録されず、モーダルが描画されなかった。
  • cleanup での ref 破棄 3 行を削除し、再マウントに耐えるよう修正。src(Metro が読む react-native/source エントリ)と lib/module / lib/commonjs の 3 経路すべてをパッチ。
  • CustomModal(= Portal)経由で開く全モーダル(設定・種別選択・テーマ・フィードバック等)が StrictMode 有効のまま表示されるようになる。本番ビルドは StrictMode 無効のため元々非発生。

テスト

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

関連Issue

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

Summary by CodeRabbit

リリースノート

  • バグ修正
    • React StrictMode での再マウント時の参照処理を改善し、安定性を向上させました。

@TinyKitten TinyKitten self-assigned this Jun 3, 2026
@coderabbitai

coderabbitai Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 972ce176-f2c8-40b8-8ea8-08425bf1069f

📥 Commits

Reviewing files that changed from the base of the PR and between f12e749 and 0373da1.

📒 Files selected for processing (1)
  • patches/@gorhom+portal+1.0.14.patch

📝 Walkthrough

Walkthrough

@gorhom/portal パッケージの patch ファイルを修正し、PortalComponent のアンマウント処理から ref クリア処理を削除。React StrictMode での remount 耐性を確保するため、CommonJS・ESM・TypeScript ソースの 3 つの形式に同一の修正とコメント説明を適用。

Changes

Portal アンマウント処理の StrictMode 対応

Layer / File(s) Summary
アンマウント時の ref クリア削除と StrictMode 対応コメント追加
patches/@gorhom+portal+1.0.14.patch
CommonJS ビルド、ESM ビルド、TypeScript ソースの useEffect クリーンアップで、handleOnMountRef / handleOnUnmountRef / handleOnUpdateRef のクリア処理を削除し、handleOnUnmountRef の呼び出しのみを残す。React 19 StrictMode での remount シミュレーション中に ref をクリアすると再登録されず表示されなくなるため、クリアしない旨の複数行コメントを追加。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

react

Poem

🐰 Strict な Mode では mount と unmount が踊り、
Portal の refs は消えずに輝く。
三つのビルド、同じ想い、
StrictMode の再マウントを優雅に生き抜く。
✨ React 19 の未来へ!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PR タイトルは React StrictMode での Portal モーダル表示問題という主要な変更を明確に説明しており、changeset と完全に関連している。
Description check ✅ Passed PR 説明では概要・変更の種類・変更内容を詳細に記述しており、テンプレートの主要セクションが充実している。ただしテスト項目がチェック未完了のままである。
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/portal-strictmode-modal-not-shown

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

@TinyKitten
TinyKitten merged commit 1e038f3 into dev Jun 3, 2026
4 checks passed
@TinyKitten
TinyKitten deleted the fix/portal-strictmode-modal-not-shown branch June 3, 2026 00:53
@TinyKitten TinyKitten mentioned this pull request Jun 3, 2026
4 of 9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant