Last active
March 2, 2018 16:58
-
-
Save bruceharris/f4209a1e6c7f8b250bfa0e9900b72d20 to your computer and use it in GitHub Desktop.
React Unit Testing Example 17
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
import React, { Component } from 'react'; | |
import logo from './logo.svg'; | |
import './App.css'; | |
import LoadingIndicator from './components/LoadingIndicator'; | |
class App extends Component { | |
state = { | |
isLoading: true, | |
}; | |
componentDidMount() { | |
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> | |
<pre>isLoading: {String(this.state.isLoading)}</pre> | |
<LoadingIndicator isLoading={this.state.isLoading}> | |
<div>ahoy!</div> | |
</LoadingIndicator> | |
</div> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment