Skip to content

Instantly share code, notes, and snippets.

@dbismut
Last active April 9, 2018 07:50
Show Gist options
  • Select an option

  • Save dbismut/4235171e06453300fcb3bbbc0b0b6155 to your computer and use it in GitHub Desktop.

Select an option

Save dbismut/4235171e06453300fcb3bbbc0b0b6155 to your computer and use it in GitHub Desktop.
Part 1 - The List component
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