Skip to content

Instantly share code, notes, and snippets.

@courtneyphillips
Last active September 13, 2017 17:54
Show Gist options
  • Save courtneyphillips/0940f4f1ecec15e4bb2827969200d0e2 to your computer and use it in GitHub Desktop.
Save courtneyphillips/0940f4f1ecec15e4bb2827969200d0e2 to your computer and use it in GitHub Desktop.
peanut butter jellyyyyy
class PeanutButterJelly extends React.Component {
constructor(props){
super(props);
this.state = {
dummyStateToTriggerUpdate: []
};
this.addToDummyState = this.addToDummyState.bind(this);
setTimeout(() =>
this.addToDummyState(),
5000
);
console.log("1.");
}
componentWillMount(){
console.log("2. ");
}
render(){
return (<div>{this.props.placeholderProp}</div>);
}
componentDidMount(){
console.log("3. ");
}
componentWillReceiveProps(){
console.log("4. ")
}
shouldComponentUpdate(){
console.log("5. ");
return true;
}
componentWillUpdate(){
console.log("6. ");
}
componentDidUpdate(){
console.log("7. ");
}
componentWillUnmount(){
console.log("8. ");
}
addToDummyState(){
this.setState({dummyStateToTriggerUpdate: "bleh"});
}
}
export default PeanutButterJelly;
class App extends React.Component {
constructor(props){
super(props);
this.state = {
dummyStateToPassAsPropToChild: []
};
this.updateDummyStateToTriggerMethodInChild = this.updateDummyStateToTriggerMethodInChild.bind(this);
}
updateDummyStateToTriggerMethodInChild(){
this.setState({dummyStateToPassAsPropToChild: "WOW ANOTHER NEW PROP"});
}
componentDidMount(){
setTimeout(() =>
this.updateDummyStateToTriggerMethodInChild(),
3000
);
}
render() {
return (
<div>
<PeanutButterjelly placeholderProp="hey"/>
</div>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment