D
D
DisaPadla2015-12-07 00:05:25
React
DisaPadla, 2015-12-07 00:05:25

Do I need to make a reducer in redux when making a POST request?

Let's say: the user fills in some data in the fields, and presses the submit button. We need to make a post request in an action in redux. Do I need to make a reducer in this case?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikita Gushchin, 2015-12-07
@iNikNik

A reducer is needed when you want to store state. This can be, for example, the status of the request - success / in progress / error. And based on this, make the "send" button inactive, show the loading indicator, etc.

A
Andrey Antropov, 2015-12-07
@Laiff

Nikita Gushchin Verno noted that about maintaining the status, I will only clarify that the place for adding calls is middleware, because otherwise the reducer will have side effects that it should not have.
For example, this middle may be interesting to send requests https://github.com/alanrubin/redux-simple-promise
Also, there is a very interesting project https://github.com/redux-effects/redux- to localize all side effects effects , now I use it in my project

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question