Last active
March 24, 2019 17:49
-
-
Save alexandrzavalii/6563aaae654814dbda6d44c3a8356424 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
class Dumbo extends React.Component { | |
state = { clothing: null, firstChild: null, secondChild: null }; | |
handleState = () => { | |
this.setState({ | |
clothing: "jeans", | |
firstChild: "shoes", | |
secondChild: "hat" | |
}); | |
}; | |
render() { | |
return ( | |
<div> | |
<h1>Hey, my name is Dumbo. </h1> | |
<p> I am wearing {this.state.clothing} today.</p> | |
<button onClick={this.handleState}>dress up</button> | |
<FirstChild clothing={this.state.firstChild} /> | |
<SecondChild clothing={this.state.secondChild} /> | |
</div> | |
); | |
} | |
} | |
const FirstChild = props => <p>I am John, and I am wearing {props.clothing} today.</p>; | |
const SecondChild = props => <p>I am Max, and I am wearing {props.clothing} today.</p>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment