Created
January 27, 2016 16:13
-
-
Save mobinni/2f7064a832fc897e4f2f to your computer and use it in GitHub Desktop.
A Modern Isomorphic Stack with Redux - Part 2
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, {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