Can a dumb component use/render redux container co

2019-03-15 04:17发布

In the getting started video of Redux we see that the Footer (a dumb component) uses Filterlink (a container).

But when I read this article, it seems, but not very clearly, that only containers should use/render containers.

For me, if Footer uses Filterlink (which is tied to Redux) I can't reuse it on other projects which don't use Redux. But maybe it is an exception? Maybe hard coding dumb component for use only on one project is ok?

Am I missing something?

1条回答
仙女界的扛把子
2楼-- · 2019-03-15 04:37

The article was somewhat out of date with how I think about it today. I just updated it so you can read it again with the fresh perspective. I’ve come to the opinion that it’s totally fine to use container components inside presentational components. The reason for this is simple: you want to be able to turn a presentational component into a container component at any time it needs too much information, and it would be a bummer if you had to convert all call sites when you do that. Therefore whether a component is presentational or a container is its implementation detail, and any components, whether presentational or containers, can use it just fine.

查看更多
登录 后发表回答