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 UserProfile from './components/UserProfile/UserProfile' | |
import Heart from './components/Heart/Heart' | |
import Comments from './components/Comments/Comments' | |
import './App.css'; | |
class App extends Component { | |
state = { | |
LikesNumber: 0, | |
ComentsNumber: 1, |
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 UserProfile from './components/UserProfile/UserProfile' | |
import Heart from './components/Heart/Heart' | |
import Comments from './components/Comments/Comments' | |
import './App.css'; |
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
class App extends Component { | |
state = { | |
LikesNumber: 0, | |
ComentsNumber: 1, | |
Comments: [{ | |
value: 'React is Awesome !!' | |
}] | |
} | |
... |
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
clickHeart = () => { | |
const likes = this.state.LikesNumber | |
this.setState({LikesNumber: likes + 1}) | |
} |
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
addComment = (newValue) => { | |
const comments = this.state.ComentsNumber | |
const arrayComments = this.state.Comments | |
const newComment = { | |
value: newValue | |
} | |
arrayComments.push(newComment) | |
this.setState({ComentsNumber: comments + 1}) | |
this.setState({Comments: arrayComments}) | |
this.setState({valueText: ''}) |
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
render() { | |
return ( | |
<div className="Container"> | |
<UserProfile | |
img='https://pbs.twimg.com/profile_images/836333218924277760/iVzLr4c-.jpg' | |
Name='Monoku' | |
Likes={this.state.LikesNumber} | |
Comments={this.state.ComentsNumber} | |
/> | |
<Heart clickHeart={this.clickHeart}/> |
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
<Comments | |
comments={this.state.Comments} | |
addComment={this.addComment} | |
changeText={this.changeText} | |
valueText={this.state.valueText} | |
/> |
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
changeText = (value) => { | |
this.setState({valueText: value}) | |
} |
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 from 'react'; | |
import PropTypes from 'prop-types'; | |
import './Comments.css'; |
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
const Comments = ({comments, addComment, changeText, valueText}) => { | |
const handleChange = (event) => { | |
changeText(event.target.value) | |
} | |
const handleClick = () => { | |
addComment(valueText) | |
} | |
const CommentList = comments.map((element, index) => { | |
return( | |
<div className='Comments' key={index}> |
OlderNewer