-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs terminology "smart" and "dumb" #170
Comments
I agree. The smart/dumb dichotomy never really made much sense to me. Another option would be "connected" and "unconnected", since "state" could be confused with React component state. A component could have React state and not be |
Imo "connected" and "unconnected" would be better, in fact I could write as follow: const MyComp = ({ myProp, myAction }) => <div>
<h1>{ myProp }</h1>
<button onClick={ myAction }>Click Me</button>
</div>
export default connect(
({ myReducer }) => ({ myProp: myReducer.myState }),
dispatch => bindActionCreator({ myAction }, dispatch)
)(MyComp) It is stateless function component while it was connected to redux, so "stateless" might be kinda confusing. +1 for "connected" and "unconnected". |
I'm up for changing it but let's choose terms carefully. |
“Stateful” and “stateless” is a different, and not necessarily relevant distinction. A component may be stateful (e.g. holding a local form or “dropdown toggled” state) but not aware of Redux. |
“Connected” and “unconnected” component is closer to the current smart/dumb distinction, but it still has some confusion potential. const Counter = ({ value, onIncrement }) =>
<div>{value} <button onClick={onIncrement}>+</button></div>;
export default connect(
state => state.counter
)(Counter); Is This is why I don't quite like saying “connected”. The argument to |
One way out of this mess is to probably stop calling “dumb” component anything special, and call the “smart” components the container components. This is consistent with Flux and Relay documentation and API. |
Containers, in my mind at least, just click when it comes to understanding the distinction |
Another vote for container here. As well as being consistent with Relay, the term is also already used in the folder structure of the Redux examples. |
Khan Academy calls these “logic components” and “presentation components”. This matches what I originally meant by “smart” and “dumb” components (before Redux or support for functional components in React) although I'm not sure I'm fond of these names. |
Worth mentioning that the Flux website also uses the terms controller-view and view. I actually think those are good descriptors, except they reek of MVC. |
In my use I've started naming my connected components In practice I connect things deeper in my tree and I don't name them al 'Connector' but then I am already eschewing the smart/dumb pattern there anyway |
For what it's worth I also like calling them container components. |
I agree with @gnoff about using the term "container." The terms "smart" and "dumb" definitely get the point across, but "container" is used elsewhere as @gaearon said (I'll throw recompose into the list as well) and does a better job describing the fact that the component is in fact wrapped by a higher-order component. Personally I think it helps demonstrate the fact that everything is in fact a "dumb" component, but some of those are just wrapped in a container. |
Presentational Components and Container Components it is. |
Hey, how about adding a reference to other-names-of-the-same-thing to the docs to avoid further confusion?
|
Happy to accept a PR. However as I wrote above, presentational components aren't necessarily stateless. |
I'd love to change the vocabulary to "stateful" and "stateless".
The text was updated successfully, but these errors were encountered: