Skip to content

Instantly share code, notes, and snippets.

@mahdiyazdani
Created September 25, 2018 19:42
Show Gist options
  • Save mahdiyazdani/ad705b5a416da79499222c3a96a78301 to your computer and use it in GitHub Desktop.
Save mahdiyazdani/ad705b5a416da79499222c3a96a78301 to your computer and use it in GitHub Desktop.
componentDidMount
import React from 'react';
import ReactDOM from 'react-dom';
export class Flashy extends React.Component {
componentWillMount() {
alert('AND NOW, FOR THE FIRST TIME EVER... FLASHY!!!!');
}
componentDidMount() {
alert('YOU JUST WITNESSED THE DEBUT OF... FLASHY!!!!!!!');
}
render() {
alert('Flashy is rendering!');
return (
<h1 style={{ color: this.props.color }}>
OOH LA LA LOOK AT ME I AM THE FLASHIEST
</h1>
);
}
}
ReactDOM.render(
<Flashy color='red' />,
document.getElementById('app')
);
setTimeout(() => {
ReactDOM.render(
<Flashy color='green' />,
document.getElementById('app')
);
}, 2000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment