Skip to content

Instantly share code, notes, and snippets.

@alexandrzavalii
Last active March 24, 2019 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexandrzavalii/296b2d9b51e3be21deed944112866847 to your computer and use it in GitHub Desktop.
Save alexandrzavalii/296b2d9b51e3be21deed944112866847 to your computer and use it in GitHub Desktop.
class Dumbo extends React.Component {
// static getDerivedStateFromProps(nextProps, prevState){ return prevState; }
state = { clothing : 'hat' };
// componentDidMount() { }
// shouldComponentUpdate() { }
// getSnapshotBeforeUpdate() { }
// componentWillUnmount() { }
handleState = () => this.setState({clothing: 'shoes'});
render() {
return(
<>
<h1>Hey, my name is Dumbo. </h1>
<p>I am wearing {this.state.clothing} today.</p>
<button onClick={this.handleState}>put on shoes instead </button>
</>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment