DEV Community

Discussion on: Different approach to loading screen in React

Collapse
 
horaceshmorace profile image
Horace Nelson • Edited

You don't really need 2 Redux actions. I really just used a second one to make it easier to simulate invalid data. The point here is that: (1) checking that your data has loaded and (2) checking that the data is valid are two different things, both of which you should do, but not at the same time.

Here's a slightly different example that illustrates a better pattern codepen.io/HoraceShmorace/pen/yLMqOVr. Note the validateData function, how validation was moved into the loadData async action, and that the setData async action was removed entirely.