S
S
samegalt2018-04-11 23:21:21
React
samegalt, 2018-04-11 23:21:21

How to avoid duplication of actions and reducers?

There is a project with a bunch of components, in which the same data can be loaded in different components (for example, a list of users). I use the same actions and reducers for loading. I do load checks, but still the application sometimes crashes with an undefined error. They suggested that you need to write your own action, your own constant and your own reducer for each loaded object. But this is kind of crazy. Or maybe I misunderstand something :( Tell me what can be done. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2018-04-12
@samegalt

The same data is loaded by the same action, into the same reducer.
The situation with users is quite clear, download them and use them on different pages. If you need to update the list of users, then the same action is called.
If you need to somehow interact with users, but in such a way that they do not change elsewhere, then explain, I can’t come up with such a case, usually this is “not the same” data.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question