Last active
April 9, 2018 07:50
-
-
Save dbismut/4235171e06453300fcb3bbbc0b0b6155 to your computer and use it in GitHub Desktop.
Part 1 - The List component
This file contains hidden or 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
| import React, { PureComponent } from 'react'; | |
| import { connect } from 'react-redux'; | |
| import { routeNodeSelector } from 'redux-router5'; | |
| import Preview from './Preview'; | |
| import './List.css'; | |
| class List extends PureComponent { | |
| render() { | |
| const { route, navigateTo } = this.props; | |
| const { posts } = route.data; | |
| return ( | |
| <div className="page full-width page-list"> | |
| <div className="list"> | |
| {posts.map(({ id, ...rest }) => ( | |
| <Preview | |
| key={id} | |
| id={id} | |
| {...rest} | |
| onClick={() => navigateTo('post', { id })} | |
| /> | |
| ))} | |
| </div> | |
| </div> | |
| ); | |
| } | |
| } | |
| export default connect(state => routeNodeSelector('home'))(List); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment