useReducer dispatch flow clarification
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 11.8k
- フォーク
- 7.9k
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 11
説明
Hi,
I've been looking around to try to find out more about the "dispatch / render" flow and can not find anything relevant yet.
My question is: when I do 2 dispatchsequentially such as:
dispatch({type: ACTION_1});
dispatch({type: ACTION_2});
Are we sure that the 2 actions will be processed before the next rendering cycle occurs?
Could it be that on the next rendering cycle, only ACTION_1 has been processed then ACTION_2 is processed on a later rendering cycle?
In other words, from the react perspective, is doing:
dispatch({type: ACTION_1});
dispatch({type: ACTION_2});
equivalent to:
dispatch({type: ACTIONS: payload: [ACTION_1, ACTION2]});
In a small demo, it seems that it doesn't matter:
https://codesandbox.io/s/tzp0s (see the console messages)
In my larger react app, it seems that often time there is a render cycle between 2 consecutive dispatch.
Is it considered an anti-pattern to do 2 dispatch sequentially and should we instead do 1 dispatch with the content of the 2 dispatch combined?
Thank you!
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
ドキュメントファイルもテストも指定されていません。まず、リンクされた CodeSandbox で逐次 dispatch の動作を再現し、説明されているより大規模なアプリケーションの動作と比較してください。完了条件は、関連する React のガイダンスを見つけ、dispatch と render の関係および推奨される使用方法を明確にすることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, react
- 領域
- documentation, frontend
- issue の種類
- ドキュメント
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 35/100