Recoilの公式ドキュメントをgoogle翻訳するとコードまで翻訳されてしまうのが面倒なのでQiitaにまとめてみます。
追々追加していきます。(多分)
目次
- 前書き ① ② ③ ④
- 基本チュートリアル ⑤ ⑥ ⑦
- ガイド ⑧ ⑨ ⑩
-
APIリファレンス
- Core ⑪ ⑫ ⑬ ⑭ ⑮ ⑯ ⑰ ⑱ ⑲ ⑳ ㉑ ㉒ ㉓ ㉔ ㉕ ㉖ ㉗
-
実用(utils)
• ㉘atomFamily()
• ㉙selectorFamily()
• ㉚ constSelector()
• ㉛errorSelector()
• ㉜waitForAll()
• ㉝waitForAny()
• ㉞waitForNone()
• ㉟noWait()
※全目次は一番下にあります
constSelector(constant)
常に一定の値を提供するselector.
function constSelector<T: Parameter>(constant: T): RecoilValueReadOnly<T>
constSelector
は、異なるselector実装によって提供されるRecoilValue<T>
やRecoilValueReadOnly<T>
などのタイプを使用するインタフェースがある場合に便利です。
これらのselectorは、参照値の等価性に基づいて記憶します。したがって、constSelector()
を同じ値で複数回呼び出すことができ、同じselectorが提供されます。このため、定数として使用される値は、Recoil serializationを使用してシリアライズできる型に制限されます。制限については、selectorFamily
のドキュメントを参照してください。
サンプルコード
type MyInterface = {
queryForStuff: RecoilValue<Thing>,
...
};
const myInterfaceInstance1: MyInterface = {
queryForStuff: selectorThatDoesQuery,
};
const myInterfaceInstance2: MyInterface = {
queryForStuff: constSelector(thing),
};
参考サイト
・公式ドキュメント
・IT用語辞典 e-Words シリアライズ
・みらい翻訳
全目次
- 前書き
- 基本チュートリアル
- ガイド
- APIリファレンス
- Core
• ⑪ <RecoilRoot />
• State
・ ⑫atom()
・ ⑬selector()
・ ⑭Loadable
・ ⑮useRecoilState()
・ ⑯useRecoilValue()
・ ⑰useSetRecoilState()
・ ⑱useResetRecoilState()
・ ⑲useRecoilValueLoadable()
・ ⑳useRecoilStateLoadable()
・ ㉑isRecoilValue()
• Snapshots
・ ㉒Snapshot
・ ㉓useRecoilTransactionObserver()
・ ㉔useRecoilSnapshot()
・ ㉕useGotoRecoilSnapshot()
• ㉖useRecoilCallback()
• 雑録(Misc)
・ ㉗useRecoilBridgeAcrossReactRoots()
- 実用(utils)
• ㉘atomFamily()
• ㉙selectorFamily()
• ㉚ constSelector()
• ㉛errorSelector()
• ㉜waitForAll()
• ㉝waitForAny()
• ㉞waitForNone()
• ㉟noWait()