F
F
fierfoxik2017-06-15 15:38:21
React
fierfoxik, 2017-06-15 15:38:21

Is the application logic correct in react/redux?

Есть 2 текстовых инпута и кнопка добавить.
После нажатия мы должны взять данные из инпутов и от рисовать их.
При нажатии на кнопку начинаем принимать данные из инпутов,
передаем в редьюсер
передаем в actions что мы получили данные
и далее в actions передает ответ в редьюсер что нужно взять принятые данные и передать их в шаблон для отрисовки
так обычно делается?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2017-06-15
@fierfoxik

When the button is clicked, an action is generated - type: "BUTTON_Pressed" (1) , in its payload (payload, the field can be called whatever you like): what kind of button it is.
This data is processed in the reducer (2) . For example: it was empty, after BUTTON_Pressed it became "in".
The connected (using connect) components saw this change in the reducer. And re-rendered*. (3)
* - if you do not interfere with render'y in any way (for example: do not pass the same object, or use some condition in shouldComponentUpdate ,)
---
Another option is that you have all 1 component (or 1 component + children) and you don't need to push data through store (i.e. action + reducer...), but you can just use state.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question