Skip to content

Instantly share code, notes, and snippets.

@bruceharris
Last active March 2, 2018 16:58
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 bruceharris/f4209a1e6c7f8b250bfa0e9900b72d20 to your computer and use it in GitHub Desktop.
Save bruceharris/f4209a1e6c7f8b250bfa0e9900b72d20 to your computer and use it in GitHub Desktop.
React Unit Testing Example 17
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