Created
April 6, 2016 18:14
-
-
Save kuy/56f25ead48445a4e4054d27d2233faf1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Presentational コンポーネント | |
class List extends Component { | |
render() { | |
const { items, onClick } = this.props; | |
return <ul> | |
{items.map(item => | |
<li onClick={() => onClick(item)}>{item}</li> | |
)} | |
</ul>; | |
} | |
} | |
// ??? | |
class App extends Component { | |
handleClick(item) { | |
this.props.dispatch(...); | |
} | |
render() { | |
const { items } = this.props; | |
return <List items={items} onClick={this.handleClick.bind(this)} />; | |
} | |
} | |
function select({ data }) { | |
return { items: data.items }; | |
} | |
// Container コンポーネント | |
const ConnectedApp = connect(select)(App); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment