useReducer dispatch flow clarification
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 11.8k
- Forks
- 7.9k
- Merge medio
- 1 d 11 h
- PR fusionados (30 d)
- 11
Descripción
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!
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
No se menciona ningún archivo de documentación ni ninguna prueba. Comienza reproduciendo el comportamiento de dispatch secuencial en el CodeSandbox enlazado y comparándolo con el comportamiento de la aplicación más grande descrito; el trabajo estaría terminado cuando se haya localizado la guía relevante de React y se hayan aclarado la relación entre dispatch y renderizado, y el uso recomendado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, react
- Área
- documentation, frontend
- Tipo de issue
- Documentación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 35/100