Skip to content

Instantly share code, notes, and snippets.

@mobinni
Created January 27, 2016 16:13
Show Gist options
  • Save mobinni/2f7064a832fc897e4f2f to your computer and use it in GitHub Desktop.
Save mobinni/2f7064a832fc897e4f2f to your computer and use it in GitHub Desktop.
A Modern Isomorphic Stack with Redux - Part 2
import React, {Component} from 'react';
import {Link} from 'react-router';
import feed from '../../../../lib/modules/feed';
import {connect} from 'react-redux';
if(process.env.BROWSER) {
require('../../../../styles/components/feed.scss');
}
class Feed extends Component {
constructor(props, context) {
super(props, context);
}
componentWillMount() {
const dispatch = this.props.dispatch;
dispatch(feed().actions.loadFeeds());
}
render() {
const {feeds} = this.props || [];
console.log(feeds);
return (
<div>
<ul>
{
feeds.map((feed, i) => {
return (<Link to={`/feed/${i}`}>{feed}</Link>)
})
}
</ul>
</div>
)
}
}
function mapStateToProps(state) {
return { feeds: state.feeds }
}
export default connect(mapStateToProps)(Feed);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment