|
1 | | -import { BaseOpenTelemetryComponent } from '@opentelemetry/plugin-react-load' |
| 1 | +/* |
| 2 | + * Copyright The OpenTelemetry Authors |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +'use strict'; |
| 18 | + |
| 19 | +import { BaseOpenTelemetryComponent } from '@opentelemetry/plugin-react-load'; |
2 | 20 |
|
3 | 21 | class Content extends BaseOpenTelemetryComponent { |
4 | | - constructor(props){ |
5 | | - super(props) |
| 22 | + constructor(props) { |
| 23 | + super(props); |
6 | 24 | this.state = { |
7 | 25 | results: null, |
8 | | - isLoading: false |
9 | | - } |
| 26 | + isLoading: false, |
| 27 | + }; |
10 | 28 | } |
11 | 29 |
|
12 | | - componentDidMount(){ |
| 30 | + // eslint-disable-next-line class-methods-use-this |
| 31 | + componentDidMount() { |
13 | 32 | // Example, do something here |
14 | 33 | } |
15 | 34 |
|
16 | 35 | buttonHandler() { |
17 | | - this.setState({isLoading: true}) |
18 | | - const randomDelay = Math.random() * 10000; |
| 36 | + this.setState({ isLoading: true }); |
| 37 | + const randomDelay = Math.random() * 10000; |
19 | 38 | setTimeout(() => { |
20 | 39 | this.setState({ |
21 | 40 | isLoading: false, |
22 | | - results: randomDelay |
23 | | - }) |
24 | | - }, |
25 | | - randomDelay); |
| 41 | + results: randomDelay, |
| 42 | + }); |
| 43 | + }, randomDelay); |
26 | 44 | } |
27 | 45 |
|
28 | | - renderResults(){ |
29 | | - if(this.state.isLoading){ |
| 46 | + renderResults() { |
| 47 | + if (this.state.isLoading) { |
30 | 48 | return <div> Loading results...</div>; |
31 | | - } |
32 | | - if (!this.state.results){ |
33 | | - return ( |
34 | | - <div>No Results</div> |
35 | | - ) |
36 | 49 | } |
37 | | - return ( |
38 | | - <div> |
39 | | - Request was delayed {this.state.results} ms |
40 | | - </div> |
41 | | - ) |
| 50 | + if (!this.state.results) { |
| 51 | + return <div>No Results</div>; |
| 52 | + } |
| 53 | + return <div>Request was delayed {this.state.results} ms</div>; |
42 | 54 | } |
43 | 55 |
|
44 | 56 | render() { |
45 | 57 | return ( |
46 | 58 | <div> |
47 | 59 | <h1>React Plugin Demo App</h1> |
48 | | - <button onClick={() => this.buttonHandler()} style={{marginBottom: '20px'}}> |
| 60 | + <button |
| 61 | + onClick={() => this.buttonHandler()} |
| 62 | + style={{ marginBottom: '20px' }} |
| 63 | + > |
49 | 64 | Make Request |
50 | 65 | </button> |
51 | | - <div id="results"> |
52 | | - {this.renderResults()} |
53 | | - </div> |
| 66 | + <div id="results">{this.renderResults()}</div> |
54 | 67 | </div> |
55 | | - ) |
| 68 | + ); |
56 | 69 | } |
57 | 70 | } |
58 | | - |
| 71 | + |
59 | 72 | export default Content; |
0 commit comments