Skip to content

Commit

Permalink
Illustrate component behavior in App.js
Browse files Browse the repository at this point in the history
  • Loading branch information
bruceharris committed Dec 6, 2017
1 parent 113608d commit cb524ca
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,30 @@ import './App.css';
import LoadingIndicator from './components/LoadingIndicator';

class App extends Component {
state = {
isLoading: true,
};

componentWillMount() {
this._timer = setTimeout(
() => this.setState({isLoading: false}),
2000
);
}

componentWillUnmount() {
clearTimeout(this._timer);
}

render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
</header>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
<LoadingIndicator isLoading={false}>
<pre>isLoading: {String(this.state.isLoading)}</pre>
<LoadingIndicator isLoading={this.state.isLoading}>
<div>ahoy!</div>
</LoadingIndicator>
</div>
Expand Down

0 comments on commit cb524ca

Please sign in to comment.