Skip to content

Instantly share code, notes, and snippets.

@kuy
Created April 6, 2016 18:14
Show Gist options
  • Save kuy/56f25ead48445a4e4054d27d2233faf1 to your computer and use it in GitHub Desktop.
Save kuy/56f25ead48445a4e4054d27d2233faf1 to your computer and use it in GitHub Desktop.
// 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