John Smith
John Smith

Reputation: 4353

Fetching from store vs. letting the parent fetch and deliver via props

Too many times when developing a component, I find myself wondering whether the component should fetch its data directly from the store, or have it passed via props - presumably to let the parent (or any higher ancestor) fetch it instead. Also, I tend not to split between smart/dumb components. What do you think about it? What are the tradeoffs?

As I see it, the tradeoff for having a direct fetch vs pass-via-props is:

Upvotes: 2

Views: 678

Answers (1)

Nikhil Goyal
Nikhil Goyal

Reputation: 1973

If the same data is being used by many components, it is better to fetch it via the store. The other advantage is, if there is a need to pass data to the n-level nested component, where n is quite big, it is better to use the store rather than passing props as it may make your component simpler to write.

These are the reasons I prefer using the store. But it is not a generic answer. One can have their own perceptions of this.

Upvotes: 2

Related Questions