chantastic / reactpatterns

Patterns for React Developers
http://reactpatterns.com
1.73k stars 101 forks source link

Question: Component Container and State Hoisting #37

Closed widdde closed 4 years ago

widdde commented 6 years ago

Hello! I have read all your react patterns and think it is a good approach. :) But I have one question that is a bit unclear in your explanations; You say the following: “A container does data fetching and then renders its corresponding sub-component. That’s it.”

In the "State hoisting" chapter you say that "Events are changes in state. Their data needs to be passed to stateful container components parents."

Is the purpose to have one container for state updates and one container for fetching data or do you think it's ok to mix fetching data (e.g. from a server) and state updates in the same component container?

Thanks in advance!

chantastic commented 4 years ago

@widdde I'm so sorry that it took me 2 years to get to the issues on this repo 😬

To answer your question, I I would use two different state providers for this.

How did you end up solving this problem in your code?