Created
October 30, 2016 16:31
-
-
Save eHammarstrom/0271162ee33b613239a08d884b722ffb to your computer and use it in GitHub Desktop.
This file contains 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 { ProviderTypes } from 'react-redux'; | |
import './Post.css'; | |
class Post extends Component { | |
constructor(props) { | |
super(props); | |
this.props = props; | |
} | |
render() { | |
return ( | |
<div key={this.props.item_key} className="Post"> | |
<h4>{this.props.user.toUpperCase()}</h4> | |
<div className="image-container"> | |
<img alt="post" src={this.props.image} /> | |
<div className="voting"> | |
<i className="material-icons yes">keyboard_arrow_up</i> | |
<i className="material-icons no">keyboard_arrow_down</i> | |
</div> | |
</div> | |
<p>{this.props.text}</p> | |
</div> | |
); | |
} | |
} | |
// <p><span>{this.props.user.toUpperCase()}</span>{this.props.text}</p> | |
export default Post; |
This file contains 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 { connect/*, ProviderTypes*/ } from 'react-redux'; | |
import Post from './Post'; | |
import './PostList.css'; | |
class PostList extends Component { | |
constructor(props) { | |
super(props); | |
this.props = props; | |
} | |
render() { | |
return ( | |
<div className="PostList"> | |
{ | |
this.props[this.props.tag].map((item) => { | |
return( | |
<Post | |
item_key={item.key} | |
key={item.key} | |
user={item.user} | |
image={item.image} | |
text={item.text} | |
/> | |
); | |
}) | |
} | |
</div> | |
); | |
} | |
} | |
const mapStateToProps = (state) => { | |
return state.posts; | |
} | |
PostList = connect(mapStateToProps)(PostList); | |
export default PostList; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment