From d25a40cbbcb2bfc57cf4e35d6d4e610f7b14482b Mon Sep 17 00:00:00 2001 From: Cam Song Date: Sat, 14 Nov 2015 11:27:44 +0800 Subject: [PATCH] rename smart/dumb to presentational/container --- docs/advanced/ExampleRedditAPI.md | 4 ++-- docs/basics/ExampleTodoList.md | 4 ++-- docs/basics/UsageWithReact.md | 16 ++++++++-------- docs/recipes/ReducingBoilerplate.md | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/advanced/ExampleRedditAPI.md b/docs/advanced/ExampleRedditAPI.md index 008fc40d63..3c55a60fcc 100644 --- a/docs/advanced/ExampleRedditAPI.md +++ b/docs/advanced/ExampleRedditAPI.md @@ -180,7 +180,7 @@ export default function configureStore(initialState) { } ``` -## Smart Components +## Container Components #### `containers/Root.js` @@ -310,7 +310,7 @@ function mapStateToProps(state) { export default connect(mapStateToProps)(AsyncApp) ``` -## Dumb Components +## Presentational Components #### `components/Picker.js` diff --git a/docs/basics/ExampleTodoList.md b/docs/basics/ExampleTodoList.md index 39c7e4e500..dc2413871b 100644 --- a/docs/basics/ExampleTodoList.md +++ b/docs/basics/ExampleTodoList.md @@ -114,7 +114,7 @@ const todoApp = combineReducers({ export default todoApp ``` -## Smart Components +## Container Components #### `containers/App.js` @@ -187,7 +187,7 @@ function select(state) { export default connect(select)(App) ``` -## Dumb Components +## Presentational Components #### `components/AddTodo.js` diff --git a/docs/basics/UsageWithReact.md b/docs/basics/UsageWithReact.md index 31a16eb3b3..008c71abdd 100644 --- a/docs/basics/UsageWithReact.md +++ b/docs/basics/UsageWithReact.md @@ -14,18 +14,18 @@ We will use React to build our simple todo app. npm install --save react-redux ``` -## Smart and Dumb Components +## Container and Presentational Components -React bindings for Redux embrace the idea of [separating “smart” and “dumb” components](https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0). +React bindings for Redux embrace the idea of [separating container and presentational components](https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0). -It is advisable that only top-level components of your app (such as route handlers) are aware of Redux. Components below them should be “dumb” and receive all data via props. +It is advisable that only top-level components of your app (such as route handlers) are aware of Redux. Components below them should be presentational and receive all data via props. - - + + @@ -52,7 +52,7 @@ It is advisable that only top-level components of your app (such as route handle
“Smart” Components“Dumb” ComponentsContainer ComponentsPresentational Components
-In this todo app, we will only have a single “smart” component at the top of our view hierarchy. In more complex apps, you might have several of them. While you may nest “smart” components, we suggest that you pass props down whenever possible. +In this todo app, we will only have a single container component at the top of our view hierarchy. In more complex apps, you might have several of them. While you may nest container components, we suggest that you pass props down whenever possible. ## Designing Component Hierarchy @@ -75,13 +75,13 @@ I see the following components (and their props) emerge from this brief: - `filter: string` is the current filter: `'SHOW_ALL'`, `'SHOW_COMPLETED'` or `'SHOW_ACTIVE'`. - `onFilterChange(nextFilter: string)`: Callback to invoke when user chooses a different filter. -These are all “dumb” components. They don’t know *where* the data comes from, or *how* to change it. They only render what’s given to them. +These are all presentational components. They don’t know *where* the data comes from, or *how* to change it. They only render what’s given to them. If you migrate from Redux to something else, you’ll be able to keep all these components exactly the same. They have no dependency on Redux. Let’s write them! We don’t need to think about binding to Redux yet. You can just give them fake data while you experiment until they render correctly. -## Dumb Components +## Presentational Components These are all normal React components, so we won’t stop to examine them in detail. Here they go: diff --git a/docs/recipes/ReducingBoilerplate.md b/docs/recipes/ReducingBoilerplate.md index a39ce819f2..a5d4d1f4d4 100644 --- a/docs/recipes/ReducingBoilerplate.md +++ b/docs/recipes/ReducingBoilerplate.md @@ -323,7 +323,7 @@ export default connect(state => ({ }))(Posts) ``` -This is much less typing! If you’d like, you can still have “vanilla” action creators like `loadPostsSuccess` which you’d use from a “smart” `loadPosts` action creator. +This is much less typing! If you’d like, you can still have “vanilla” action creators like `loadPostsSuccess` which you’d use from a container `loadPosts` action creator. **Finally, you can write your own middleware.** Let’s say you want to generalize the pattern above and describe your async action creators like this instead: