Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
解剖"React Native"
Search
hacusk
April 08, 2026
Technology
150
0
Share
解剖"React Native"
React .study vol.01@sapporo
https://hokkaido-js.connpass.com/event/388202/
hacusk
April 08, 2026
More Decks by hacusk
See All by hacusk
DuckDB-Wasmを使って ブラウザ上でRDBMSを動かす
hacusk
1
450
バックエンドの技術をブラウザで動かす技術
hacusk
0
120
形なしからの脱却
hacusk
0
32
Other Decks in Technology
See All in Technology
(きっとたぶん)人材育成や教育のような何かの話
sejima
0
750
2026年春のAgentCoreアプデ 細かいやつ全部まとめ
minorun365
4
240
ECSのTerraformモジュールにコントリビュートした話
harukasakihara
0
210
続 運用改善、不都合な真実 〜 物理制約のない運用改善はほとんど無価値 / 20260518-ssmjp-kaizen-no-value-without-physical-constraints
opelab
2
230
JaSSTに関わることで変わった人生観 #jasstnano
makky_tyuyan
0
100
生成AI時代に信頼性をどう保ち続けるか - Policy as Code の実践
akitok_
1
430
【関西製造業祭り2026春】現場を変える技術はここまで来た〜世界最大の製造業見本市から持って帰ってきたもの〜
tanakaseiya
0
170
毎日の作業を Claude Code 経由にしたら、 ノウハウがコードになった
kossykinto
1
1.4k
開発サイクルのボーダーレス化に伴う組織変革から学んだこと / Organizational Transformation Amid the Borderless Development Cycle
mii3king
0
110
マンション備え付けのネットワークとLTE回線を組み合わせた ネットワークの安定化の考案
harutiro
1
130
全社統制を維持しながら現場負担をどう減らすか〜プラットフォームチームとセキュリティチームで進めたSecurity Hub活用によるAWS統制の見直し〜/secjaws-security-hub-custom-insights
mhrtech
1
540
AI時代に、 データアナリストがデータエンジニアに異動して
jackojacko_
0
940
Featured
See All Featured
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
220
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3k
How to Ace a Technical Interview
jacobian
281
24k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
340
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
210
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
280
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
1.4k
The Spectacular Lies of Maps
axbom
PRO
1
740
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
190
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.7k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Transcript
解剖"React Native" HakataYusuke(@hacusk) 2026.04.08(Wed.) React.study vol.01@sapporo 1
$ whoami Name: はくすけ(@hacusk) / HakataYusuke Job: 株式会社モニクル SWE Language:TypeScript,
Go, PHP… FavoriteTech: MultiPlatformなもの, OSS, ネ ットワーク Love: 声優, 旅行, ライブ, アイドル, 車, モータ ースポーツ, ガジェット, 飛行機, 麻雀 Community: 函館本線沿線勉強会, フロントエ ンドカンファレンス北海道実行委員会, OSC北 海道実行委員会, 一般社団法人LOCAL Website: https://hacusk.net/ 2
What is "React Native" Learn once, write anywhere. Meta社が主に開発しているOSSのマルチプラットフォームフレームワーク Callstack,Expo,Infinite
Red,Microsoft,Software Mansion社も大きく関わっている iOS,Android,tvOS,Android TV,Vega OS,macOS,Windows(UWP),Meta Horizon OS,Webなどで動くものを作れる ※一部はReactNativeからforkされているプロジェクト(意外なことにfor macOSはMicrosoft が面倒を見ている) https://reactnative.dev/docs/out-of-tree-platforms Reactとそのネイティブ側のプラットフォームの機能を組み合わせてアプリケーションを作る 既存のネイティブコードをラップしたReactのコンポーネントを用いて,JavaScriptを介してネ イティブのAPIを実行する 3
今日話すこと ReactNativeがどのようにして実行されているのかを紐解く 各プラットフォーム上でJavaScriptを動かすための仕組み — Metro Bundler / Hermes JavaScriptとプラットフォームAPIをつなぐための仕組み —
JSI 接続を保証する仕組み — Codegen / TurboModules Reactを動かす仕組み — Fabric / Yoga 前提: iOS,Androidをターゲットとした前提で話します react-native 0.76以降で有効化されているNew Architectureの話です 4
ReactNativeのアーキテクチャ全体像 JS 側 React / App code JSX コンポーネント Hermes
JSエンジン Codegen ビルド時 · 型定義⾃動⽣成 JSI JavaScript Interface C++ · 同期 · シリアライズなし Native 側 TurboModules 初回呼び出し時に C++ インスタンス⽣成 Fabric React レンダラー · immutable な C++ ツリー Yoga Flexbox 計算 (C++ 実装) iOS APIs UIKit · SwiftUI Android APIs View · Jetpack 5
Metro Bundler コードのバンドル,最適化,バイトコードの生成 主な機能 JSX → JS 変換(Babel) モジュール解決 minify,Tree
shaking RN固有の役割 HMR(Hot Module Replacement) Platform-specific extensions Hermes向けバイトコード出力 $ pnpm expo export → JavaScript bytecode https://metrobundler.dev/ https://reactnative.dev/docs/metro 6
Hermes リリースビルド時(AOT) 1. Metroがコードをバンドル 2. HermesコンパイラがJSをバイトコード (.hbc)に変換 3. APK /
IPAに同梱して配布 実行側 バイトコードをそのまま実行(AOTコンパイル 済み) JIT不要 → 起動時のコンパイルコストがゼロ シングルスレッド・イベントループ イベントループの実行順 // HermesInternal でエンジン確認 const isHermes = !!global.HermesInternal; // true console.log('1. 同期処理'); // Call Stack Promise.resolve().then(() => { console.log('2. Microtask'); // Microtask Queue }); setTimeout(() => { console.log('3. Task'); // Task Queue }, 0); // 出力順: 1 → 2 → 3 デバッグモードではMetroからJSを配布し,JITで実行 https://reactnative.dev/docs/hermes https://reactnative.dev/architecture/bundled-hermes 7
JSI — JavaScript Interface シリアライズなし JSオブジェクトをC++ポイン タで直接参照 同期呼び出し可能 await なしでNativeから即座
に値を受け取れる Codegen連携 TSの型定義から C++,Java,ObjCのI/Fを自動生 成 // C++側: HostObjectとして公開 class NativeCalculator : public HostObject { public: Value get(Runtime& rt, const PropNameID& name) override { // JSオブジェクトをコピーなしで直接参照 return Function::createFromHostFunction(rt, ...); } }; https://reactnative.dev/architecture/landing-page 8
Codegen TSの型定義を唯一の情報源とする export interface Spec extends TurboModule { multiply(a: number,
b: number): number; fetchData(url: string): Promise<string>; } export default TurboModuleRegistry.getEnforcing<Spec>('Calculator'); ↓ Codegenが自動生成 class NativeCalculatorCxxSpec { public: virtual double multiply(jsi::Runtime& rt, double a, double b) = 0; virtual jsi::Value fetchData(jsi::Runtime& rt, jsi::String url) = 0; }; 型ズレによるランタイムクラッシュが原理的に起きにくくなる https://reactnative.dev/docs/the-new-architecture/what-is-codegen 9
TurboModules 初回呼び出し時にC++インスタンス生成 JSIのHostObjectとして登録 同期呼び出し可能(JSIのおかげ) Codegenで型安全が保証される 旧NativeModulesは起動時に全モジュールを一括登録していたため,メモリ消費や起動遅延の原因に なっていた https://reactnative.dev/docs/turbo-native-modules-introduction 10
TurboModules — Platform.constantsで読む実装の流れ① // ① JS Spec — 型の定義(Codegenの入力) //
NativePlatformConstantsIOS.js export interface Spec extends TurboModule { getConstants(): { osVersion: string; reactNativeVersion: {...}; ... }; } export default TurboModuleRegistry.getEnforcing<Spec>('PlatformConstants'); // ② iOS実装 — RCTPlatform.mm RCT_EXPORT_MODULE(PlatformConstants) // モジュール名を登録 - (ModuleConstants)getConstants { return typedConstants<JS::NativePlatformConstantsIOS::Constants>({ .osVersion = [UIDevice currentDevice].systemVersion, ... }); } 11
TurboModules — Platform.constantsで読む実装の流れ② // ③ Android実装 — AndroidInfoModule.kt @ReactModule(name =
NativePlatformConstantsAndroidSpec.NAME) class AndroidInfoModule : NativePlatformConstantsAndroidSpec(reactContext) { override fun getTypedExportedConstants() = mapOf( "Release" to Build.VERSION.RELEASE, "Model" to Build.MODEL, ... ) } https://github.com/reactwg/react-native-new-architecture/blob/main/docs/turbo-modules.md 12
Fabricのレンダリングパイプライン Phase 1 — Render(JSスレッド) ReactがElement Treeを生成 → JSI経由でC++のShadow Treeにミラーリング
Phase 2 — Commit(C++スレッド) BeforeMutation → Mutation(差分適用)→ Layout(Yoga・Flexbox計算) JSスレッドをブロックしない Phase 3 — Mount(メインスレッド) 確定した座標でiOS UIView / Android Viewを同期更新 startTransition → Renderフェーズを低優先度に Suspense → Shadow Tree構築を保留しfallbackをMount https://reactnative.dev/architecture/render-pipeline 13
YogaとShadow Tree Shadow Tree C++でReact Element Treeをミラーリング immutable — 並列に複数バージョン保持可能
これがConcurrent Featuresの土台 Yoga Flexboxレイアウトエンジン(C++実装) WebのCSSとほぼ同じAPIで計算 CommitフェーズのLayoutサブフェーズで動く // Shadow TreeはJSスレッドと同期しているので同期的に正確な座標が返る const boxRef = useRef<View>(null); boxRef.current?.measureInWindow((x, y, width, height) => { console.log(`x:${x} y:${y} w:${width} h:${height}`); }); https://reactnative.dev/architecture/glossary#react-shadow-tree-and-react-shadow-node 14
まとめ: React Nativeにおける"React" React自体はWeb版とまったく同じでコンポーネント・状態管理などがそのまま動くが, レンダラーだけ違う Webの場合 reconciler(Fiber)が差分を計算 react-dom がDOMを更新 React
Nativeの場合 reconciler(Fiber)が差分を計算(同じ) Fabric がNative UIツリーを更新 React NativeでDOMイベント等は使えないなどの制約はある https://reactnative.dev/architecture/fabric-renderer 15