---
title: "React is React, just. Part 2"
description: "エッセイ: MetaとBabelとFlowとReact Compiler React is React, just. Part 2について，ubugeeei が wtrclred に書いた記事です．"
last_updated: "2026-11-15"
canonical_url: "https://wtrclred.vercel.app/ja/posts/08"
language: "ja"
---

Turn on watercolor background effects. * May affect performance, battery life, and temperature on some devices.

### 目次

- [MetaとJavaScriptインフラ](#metaとjavascriptインフラ)
- [Babel](#babel)
- [Flow](#flow)
- [FlowのComponent SyntaxとHook Syntax](#flowのcomponent-syntaxとhook-syntax)
- [なぜ追加されたのか](#なぜ追加されたのか)
- [Component Syntaxの構文](#component-syntaxの構文)
- [Hook Syntaxの構文](#hook-syntaxの構文)
- [Flowが検出するもの](#flowが検出するもの)
- [これが意味すること](#これが意味すること)
- [React Compiler: 暗黙的なアプローチ](#react-compiler-暗黙的なアプローチ)
- [React Compilerの歴史](#react-compilerの歴史)
- [Hooks: Reactを「言語」として定義した瞬間](#hooks-reactを-言語-として定義した瞬間)
- [Hooksの設計とコンパイラ](#hooksの設計とコンパイラ)
- [Dan Abramovの発言](#dan-abramovの発言)
- [React Compilerが行うこと](#react-compilerが行うこと)
- [条件付きメモ化: useMemoでは不可能なこと](#条件付きメモ化-usememoでは不可能なこと)
- [Rules of Reactの静的強制](#rules-of-reactの静的強制)
- [Metaでの成果](#metaでの成果)
- [React CompilerとFlowの連携](#react-compilerとflowの連携)
- [compilationModeオプション](#compilationmodeオプション)
- ['syntax'モード](#syntax-モード)
- [これが意味すること](#これが意味すること)
- [Reactドキュメントとfunctionキーワード](#reactドキュメントとfunctionキーワード)
- [なぜアロー関数ではないのか](#なぜアロー関数ではないのか)
- [1. FlowのComponent Syntaxとの親和性](#1-flowのcomponent-syntaxとの親和性)
- [2.構文の一貫性](#2-構文の一貫性)
- [二つのアプローチの対比](#二つのアプローチの対比)
- [Rules of React](#rules-of-react)
- [結論: Reactは「言語」として進化している](#結論-reactは-言語-として進化している)

> 注意 : 筆者はMetaの関係者でもReact Compilerの関係者でもありません．本記事はあくまで外部から観測できる情報に基づいた考察です．

 [前回の記事](/posts/01)では，React Compilerの登場によってReact Componentが「Just JavaScript」ではなくなったのではないか，という議論をした．
今回はその続きとして，Metaのエコシステム全体を俯瞰し，Reactが「言語」として進化していく様子をより深く考察する．

# Metaと JavaScriptインフラ

 Meta (旧Facebook)はJavaScriptのエコシステムに対して長年にわたり大きな貢献をしてきた．

## Babel

 [Babel](https://babeljs.io/)は，もともと6to5という名前で始まったJavaScriptのトランスパイラだ．
ES6+やJSXなど，ブラウザがネイティブにサポートしていない構文を変換し，後方互換性を保つ役割を担っている．

> JSX was created as an extension to ECMAScript with the purpose of designing a more concise and easy-to-understand syntax for building DOM tree structures and attributes. — [The Role of Babel in React](https://medium.com/swlh/the-role-of-babel-in-react-dbcf78c69125)

 Babelは独立したオープンソースプロジェクトだが，Reactのエコシステムにおいて不可欠な存在だ．
そして， React CompilerもBabel Pluginとして実装されている ．

## Flow

 [Flow](https://flow.org/)はMetaが開発しているJavaScriptの静的型チェッカーだ．
 FlowもBabel Plugin (`@babel/preset-flow`)として実装されており ，型注釈や独自構文を実行時に削除する役割を担っている．

 そして今日の主題の一つとして， Flowは型チェッカーを超えて「言語」としての拡張を行っている ．

# Flowの Component Syntaxと Hook Syntax

 2024年4月，Flowチームは[Component Syntax](https://flow.org/blog/2024/04/03/New-Flow-Language-Features-for-React/)を発表した．
これはReactのプリミティブであるコンポーネントとフックに対する 一級言語サポート だ．

## なぜ 追加されたのか

> Component Syntax was designed in coordination with the React team, and is already being used across Meta's codebases. — [New Flow Language Features for React](https://flow.org/blog/2024/04/03/New-Flow-Language-Features-for-React/)

> These features bring improved ergonomics, expressiveness, and static enforcement for many of the Rules of React . — [Flow Blog](https://flow.org/blog/2024/04/03/New-Flow-Language-Features-for-React/)

 つまり，FlowのComponent Syntaxは Reactチームと連携して設計 され， Rules of Reactを静的に強制する ことを目的としている．

## Component Syntaxの 構文

 通常の関数コンポーネントではなく，`component`キーワードを使って定義する:

 

```js
  // 従来の関数コンポーネント 
 function   Introduction  (  props  :   {   name  :   string  ,   age  :   number   }  )   { 
   return   ( 
     <  h1  > 
       My   name   is   {  props  .  name  }   and   I   am   {  props  .  age  }   years   old 
     <  /  h1  > 
   )  ; 
 } 

 // Flow の Component Syntax 
 component   Introduction  (  name  :   string  ,   age  :   number  )   { 
   return   ( 
     <  h1  > 
       My   name   is   {  name  }   and   I   am   {  age  }   years   old 
     <  /  h1  > 
   )  ; 
 }
```

 参考: [Component Syntax | Flow](https://flow.org/en/docs/react/component-syntax/)

 Component Syntaxでは:

- propsが直接パラメータになる : ボイラープレートの削減

- refの自動処理 : 内部で React.forwardRef でラップされる

- 明示的なreturnが必須 : すべてのブランチでreturnが必要

- this の使用禁止 : コンポーネント内で this は使えない

## Hook Syntaxの 構文

 同様に，`hook`キーワードを使ってフックを定義する:

 

```js
  // 従来のカスタムフック 
 function   useOnlineStatus  (  initial  :   boolean  )  :   boolean   { 
   const   [  isOnline  ,   setIsOnline  ]   =   useState  (  initial  )  ; 
   // ... 
   return   isOnline  ; 
 } 

 // Flow の Hook Syntax 
 hook   useOnlineStatus  (  initial  :   boolean  )  :   boolean   { 
   const   [  isOnline  ,   setIsOnline  ]   =   useState  (  initial  )  ; 
   // ... 
   return   isOnline  ; 
 }
```

 参考: [Hook Syntax | Flow](https://flow.org/en/docs/react/hook-syntax/)

## Flowが 検出する もの

 FlowのComponent/Hook Syntaxは，[Rules of React](https://react.dev/reference/rules)に違反するコードを 静的に 検出する:

- Propsのmutation検出 : コンポーネント内でpropsを変更しようとするコード

- 条件付きフック呼び出しの禁止 : if文内でのフック呼び出しをエラーとして報告

- レンダリング中のrefアクセス検出 : レンダリング中にrefを読み書きするコード

- ネストしたcomponent/hookの検出 : componentやhook内で別のcomponent/hookを定義するコード

> Flow is able to detect mutations of props in a component or hook. Another pattern enforced in component bodies is that refs are not read or written to during render. — [Flow Documentation](https://flow.org/en/docs/react/component-syntax/)

## これが 意味する こと

 FlowのComponent SyntaxとHook Syntaxは， Reactを「言語」として明示的に定義する試み だ．

 従来，Reactコンポーネントは「JavaScriptの関数」として定義されていた．
しかし，Flowは新しいキーワード(`component`, `hook`)を導入することで， Reactのセマンティクスを言語レベルで表現 している．

 これは前回の記事で議論した「ReactはReactだ」という結論を，より明確な形で示している．

# React Compiler: 暗黙的な アプローチ

 Flowが「明示的」に新しい構文を導入しているのに対し，React Compilerは「暗黙的」なアプローチを取っている．

## React Compilerの 歴史

 React Compilerは約10年 にわたる研究の成果だ:

- 2017年 : FacebookがPrepackでコンパイラを初めて探索

- 2021年 : Xuan Huangが新しいアプローチの[最初のイテレーション](https://www.youtube.com/watch?v=lGEMwh32soc)をデモ

- 2024年 : ベータ版リリース，React Conf 2024で発表

- 2025年10月 : [React Compiler v1.0](https://react.dev/blog/2025/10/07/react-compiler-1)安定版リリース

 参考: [React Compiler v1.0 – React](https://react.dev/blog/2025/10/07/react-compiler-1)

## Hooks: Reactを 「言語」と して 定義した 瞬間

 ここで一つの重要な視点を提示したい．

 Reactを「言語」として定義したのはHooksの登場時点だった．

 Hooksには Rules of Hooks という，JavaScriptには存在しない制約がある:

- トップレベルでのみ呼び出す (ループ，条件分岐，ネストした関数内では呼ばない)

- React関数からのみ呼び出す (通常のJavaScript関数からは呼ばない)

 これらはJavaScriptの関数には存在しないルールだ．
Hooksを使う関数は，もはや「JavaScriptの関数」ではなく 「Reactの関数」 になる．

 つまり， Hooksの導入こそが，Reactを独自のセマンティクスを持つ「言語」として定義した瞬間だった と言えるかもしれない．

## Hooksの 設計と コンパイラ

 そして，Hooksは最初からコンパイラによる最適化を前提として設計されていた．

 React Compiler v1.0のブログには以下の記述がある:

> Hooksの設計自体がコンパイラの将来を見据えて設計されました． — [React Compiler v1.0](https://react.dev/blog/2025/10/07/react-compiler-1)

 これは後付けの話ではない． 2018年に公開されたHooksの公式ドキュメント には，既にこの意図が明記されていた:

> As Svelte, Angular, Glimmer, and others show, ahead-of-time compilation of components has a lot of future potential. Especially if it's not limited to templates. — [Introducing Hooks – React (2018)](https://legacy.reactjs.org/docs/hooks-intro.html)

> We wanted to present an API that makes it more likely for code to stay on the optimizable path. To solve these problems, Hooks let you use more of React's features without classes. — [Introducing Hooks – React (2018)](https://legacy.reactjs.org/docs/hooks-intro.html)

 つまり， Hooksは最初からコンパイラによる最適化を前提として設計されていた ．

## Dan Abramovの 発言

 当時ReactチームにいたDan Abramovも，コンパイラによる自動メモ化について早い段階から言及していた．

 2021年2月に公開された記事"[Before You memo()](https://overreacted.io/before-you-memo/)"では，手動でのメモ化の手間について触れた上で，以下のように述べている:

> This last step is annoying, especially for components in between, and ideally a compiler would do it for you. In the future, it might. — Dan Abramov, [Before You memo() (2021)](https://overreacted.io/before-you-memo/)

 「将来的には，コンパイラがこれを自動で行うかもしれない」——この発言はReact Compilerが一般公開される3年以上前 のものだ．

 Reactチームは長年にわたり， コンパイラによる自動最適化 という明確なビジョンを持っていた．
これは，Reactが「Just JavaScript」から「独自のセマンティクスを持つ言語」へと進化していく過程が，計画的なものであったことを示している．

## React Compilerが 行う こと

 前回の記事でも触れたが，React Compilerは以下のような最適化を自動で行う:

 

```tsx
  // 入力 
 function   VideoTag  (  {   heading  ,   videos  ,   filter   }  )   { 
   const   filteredVideos   =   [  ]  ; 
   for   (  const   video   of   videos  )   { 
     if   (  applyFilter  (  video  ,   filter  )  )   { 
       filteredVideos  .  push  (  video  )  ; 
     } 
   } 
   // ... 
 }
```

 

```tsx
  // 出力 (コンパイル後) 
 function   VideoTab  (  t36  )   { 
   const  $  =   useMemoCache  (  12  )  ; 
   const   {   heading  ,   videos  ,   filter   }   =   t36  ; 
   let   filteredVideos  ; 

   if   ( $ [  0  ]   !  =  =   videos   |  |  $ [  1  ]   !  =  =   filter  )   { 
     filteredVideos   =   [  ]  ; 
     for   (  const   video   of   videos  )   { 
       if   (  applyFilter  (  video  ,   filter  )  )   { 
         filteredVideos  .  push  (  video  )  ; 
       } 
     } 
    $ [  0  ]   =   videos  ; 
    $ [  1  ]   =   filter  ; 
    $ [  2  ]   =   filteredVideos  ; 
   }   else   { 
     filteredVideos   =  $ [  2  ]  ; 
   } 
   // ... 
 }
```

 参考: [Understanding Idiomatic React – Joe Savona, Mofei Zhang, React Advanced 2023](https://youtu.be/qOQClO3g8-Y?t=497)

## 条件付きメモ化: useMemoでは 不可能な こと

 React Compiler v1.0のブログでは， 手動の`useMemo`/`useCallback`では実現できない最適化 の例が示されている:

 

```js
  export   default   function   ThemeProvider  (  props  )   { 
   if   (  !  props  .  children  )   { 
     return   null  ; 
   } 
   // コンパイラは条件付きリターン後のコードもメモ化できる 
   // （手動の useMemo/useCallback では不可能） 
   const   theme   =   mergeTheme  (  props  .  theme  ,   use  (  ThemeContext  )  )  ; 
   return   <  ThemeContext   value  =  {  theme  }  >  {  props  .  children  }  <  /  ThemeContext  >  ; 
 }
```

> これは useMemo / useCallback では実装できない，コンパイラ固有の能力です． — [React Compiler v1.0](https://react.dev/blog/2025/10/07/react-compiler-1)

## Rules of Reactの 静的強制

 React Compilerには Rules of Reactを検証するパス が含まれており，ESLintプラグインを通じて診断が提供される:

> React Compiler's ESLint plugin helps developers proactively identify and correct Rules of React violations. The team strongly recommends everyone use the linter today. — [React Compiler Beta Release](https://react.dev/blog/2024/10/21/react-compiler-beta-release)

## Metaでの 成果

 React Compilerは既にMetaの本番環境で運用されている:

- Instagram : 全ページで平均3%改善

- Quest Store : ロード時間が少なくとも4%改善，一部のインタラクションは2倍以上 高速化，初期ロードは最大12%改善

 参考: [React Compiler v1.0](https://react.dev/blog/2025/10/07/react-compiler-1)

# React Compilerと Flowの 連携

 ここで重要なのは， React CompilerはFlowのComponent/Hook Syntaxを明示的にサポートしている ということだ．

## compilationModeオプション

 React Compilerには[compilationMode](https://react.dev/reference/react-compiler/compilationMode)というオプションがあり，どの関数をコンパイル対象とするかを制御できる:

- 'infer' (デフォルト): コンポーネント命名規則(PascalCase)とフック検出( use プレフィックス) を使用

- 'annotation' : "use memo" ディレクティブでマークされた関数のみ

- 'syntax' : Flowのcomponent/hook構文を使用した関数のみ

- 'all' : すべてのトップレベル関数 (非推奨)

## 'syntax' モード

 `'syntax'`モードを使用すると，Flowの専用構文で定義されたコンポーネントとフックのみがコンパイル対象となる:

 

```js
  // babel.config.js 
 { 
   compilationMode  :   "syntax"  ; 
 }
```

 

```js
  // ✅ コンパイル対象：Flow component 構文 
 component   Button  (  label  :   string  )   { 
   return   <  button  >  {  label  }  <  /  button  >  ; 
 } 

 // ✅ コンパイル対象：Flow hook 構文 
 hook   useCounter  (  initial  :   number  )   { 
   const   [  count  ,   setCount  ]   =   useState  (  initial  )  ; 
   return   [  count  ,   setCount  ]  ; 
 } 

 // ❌ コンパイル対象外：通常の関数構文 
 function   helper  (  data  )   { 
   return   process  (  data  )  ; 
 }
```

 参考: [compilationMode – React](https://react.dev/reference/react-compiler/compilationMode)

## これが 意味する こと

 FlowとReact Compilerは 別々のプロジェクトではなく，連携して設計されている ．

- FlowのComponent SyntaxはReactチームと連携して設計された

- React CompilerはFlowの構文を明示的にサポートしている

- Metaの内部では，この二つが組み合わせて使用されている

 つまり，Metaは「Reactを言語として定義する」という一貫した戦略のもとで，FlowとReact Compilerの両方を開発している．

# Reactドキュメントと functionキーワード

 ここで一つの観察を共有したい．

 [Reactの公式ドキュメント](https://react.dev/)では，コンポーネントの定義に 一貫して`function`キーワード が使われている:

 

```js
  export   default   function   Profile  (  )   { 
   return   <  img   src  =  "https://i.imgur.com/MK3eW3Am.jpg"   alt  =  "Katherine Johnson"   /  >  ; 
 }
```

 参考: [Your First Component – React](https://react.dev/learn/your-first-component)

 アロー関数(`const Profile = () => {}`) についての言及は 一切ない ．

## なぜアロー関数ではないのか

 Dan Abramovは[overreacted.io](https://overreacted.io/how-are-function-components-different-from-classes/)で以下のように述べている:

> it doesn't matter whether I use arrows or function declarations — Dan Abramov

 技術的には，アロー関数でも関数宣言でもReactコンポーネントとして問題なく動作する．
しかし，Reactドキュメントが`function`キーワードを使い続けていることには，いくつかの考察ができる．

### 1. Flowの Component Syntaxとの 親和性

 FlowのComponent Syntaxは`component`キーワードを使う:

 

```js
  component   Introduction  (  name  :   string  ,   age  :   number  )   { 
   // ... 
 }
```

 これは`function`キーワードを置き換える形で自然に導入できる．
もしReactドキュメントがアロー関数を推奨していたら，この移行は不自然になる．

### 2.構文の 一貫性

 `function`キーワードによる宣言は，将来的に専用構文(FlowのComponent Syntaxのようなもの) へ移行する場合にも自然な形で置き換えられる．
アロー関数からの移行よりも，関数宣言からの移行の方が構文的に一貫性がある．

# 二つの アプローチの 対比

 FlowとReact Compilerは，同じ問題に対して異なるアプローチを取っている:

 Flow :

- 方法: 新しいキーワード( component , hook )

- 明示性: 明示的 (新構文)

- 対象: Metaの内部コードベース

- 目的: Rules of Reactの静的強制

 React Compiler :

- 方法: 既存の構文を変換

- 明示性: 暗黙的 (変換)

- 対象: 全Reactユーザー

- 目的: 自動メモ化 + Rules of Reactの検証

 しかし， どちらも「Reactは独自のセマンティクスを持つ」という方向性では一致している ．

# Rules of React

 ここで改めて[Rules of React](https://react.dev/reference/rules)を確認しておこう:

> Rulesは，アイディオマティック（慣用的）で高品質なReactコードを書くためのルールです．単なるガイドラインではなく，これに従わないとバグが生じます． — [Rules of React – React](https://react.dev/reference/rules)

 主要なルール:

- ComponentsとHooksはPure（純粋）である必要がある 冪等性: 同じ入力に対して常に同じ出力

- Side Effectsはレンダリングの外側でのみ実行

- props, state, Hookの戻り値は不変

- ReactがComponentsとHooksを呼び出す コンポーネント関数を直接呼ばない

- Hookを通常の値として渡さない

- Rules of Hooks トップレベルでのみ呼び出す

- React関数からのみ呼び出す

 これらのルールは「React的意味論」を形成している．
そして，FlowのComponent SyntaxもReact Compilerも，これらのルールを 静的に強制する ことを目指している．

# 結論: Reactは 「言語」と して 進化している

 前回の記事で私は以下のように結論した:

> Reactは，Reactだ． 構文がJavaScriptと同じで，意味が異なる別の存在だ．

 今回の調査で，この結論はさらに強化された:

- FlowのComponent Syntax は，Reactのセマンティクスを 明示的に言語として定義 している

- React Compiler は，Reactのセマンティクスを 暗黙的にJavaScriptに変換 している

- Hooksは最初からコンパイラを前提として設計されていた

- Reactドキュメントは function キーワードを一貫して使用 しており，将来の構文拡張に備えている可能性がある

 Reactが「Just JavaScript」であった時代は，徐々に終わりを迎えつつある．
 ReactはReactだ ——この言葉の意味は，今後ますます重要になっていくだろう．

 これは私の単なるエッセイであり，React TeamやMetaの公式見解ではありません．

### 関連コンテンツ

- [成果は 屍の 上に ある， そこには 先人の 努力が ある](/ja/posts/30) #oss #ai #software
- [OSS なのだから， 参加すれば 良いと いう 主張は 本当か？](/ja/posts/25) #oss #philosophy #community
- [AI 時代， 昨日までの 合理を 選び直す](/ja/posts/24) #philosophy #ai #software
- [営利企業こそ， OSS の 作り手に 金を 払え](/ja/posts/21) #oss #philosophy #sponsorship
- [corsa-bind: 言語処理系オーケストレーションと いう 考え方](/ja/posts/17) #typescript #language #compiler
- [Signalsと Signals． そして Retained UI．](/ja/posts/12) #javascript #oss #signals

[← 記事一覧に戻る](/ja)

## Sitemap

- [Browse every page on wtrclred](https://wtrclred.vercel.app/sitemap.md)
