Recoil

Motivation
動機
For reasons of compatibility and simplicity, it's best to use React's built-in state management capabilities rather than external global state. But React has certain limitations:
互換性とシンプルさの理由から、外部のグローバルステートではなくReactの組み込みステート管理機能を使用するのがベストです。しかし、Reactにはある種の限界があります。
- Component state can only be shared by pushing it up to the common ancestor, but this might include a huge tree that then needs to re-render.
コンポーネントの状態は、共通の祖先にプッシュすることでしか共有できませんが、これには巨大なツリーが含まれ、再レンダリングが必要になる可能性があります。 - Context can only store a single value, not an indefinite set of values each with its own consumers.
コンテキストは単一の値しか保存できず、それぞれが消費者を持つ不定な値のセットではありません。 - Both of these make it difficult to code-split the top of the tree (where the state has to live) from the leaves of the tree (where the state is used).
どちらも、ツリーのトップ(ステートが存在しなければならない場所)とツリーのリーフ(ステートが使用される場所)のコード分割を困難にしています。
We want to improve this while keeping both the API and the semantics and behavior as Reactish as possible.
APIもセマンティクスや動作も、できるだけReactらしさを保ちながら、これを改善していきたいと考えています。
Recoil defines a directed graph orthogonal to but also intrinsic and attached to your React tree. State changes flow from the roots of this graph (which we call atoms) through pure functions (which we call selectors) and into components. With this approach:
Recoilは、Reactツリーに直交する有向グラフを定義しますが、同時に、Reactツリーに内在し、添付されます。状態の変化は、このグラフのルート(アトムと呼びます)から、純粋な関数(セレクタと呼びます)を経て、コンポーネントに流れます。このアプローチで
- We get a boilerplate-free API where shared state has the same simple get/set interface as React local state (yet can be encapsulated with reducers etc. if needed).
共有ステートがReactのローカルステートと同じシンプルなget/setインターフェイスを持つ、ボイラープレート不要のAPIを得ることができる(それでも必要に応じてreducersなどでカプセル化することができる)。 - We have the possibility of compatibility with Concurrent Mode and other new React features as they become available.
Concurrent Modeをはじめ、Reactの新機能に順次対応していく可能性があります。 - The state definition is incremental and distributed, making code-splitting possible.
状態定義はインクリメンタルかつ分散型であるため、コード分割が可能である。 - State can be replaced with derived data without modifying the components that use it.
ステートを使用するコンポーネントを変更することなく、ステートを派生データに置き換えることができる。 - Derived data can move between being synchronous and asynchronous without modifying the components that use it.
派生データは、それを使用するコンポーネントに変更を加えることなく、同期と非同期の間を行き来することができます。 - We can treat navigation as a first-class concept, even encoding state transitions in links.
ナビゲーションを第一級の概念として扱い、状態遷移をリンクで符号化することも可能である。 - It's easy to persist the entire application state in a way that is backwards-compatible, so persisted states can survive application changes.
後方互換性のある方法でアプリケーションの状態全体を永続化することが容易であるため、永続化された状態はアプリケーションの変更に耐えることができます。