Can a dumb component use/render redux container component?

青春壹個敷衍的年華 提交于 2019-12-20 11:43:07

问题


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:


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.



来源:https://stackoverflow.com/questions/34992247/can-a-dumb-component-use-render-redux-container-component

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!