Skip to content

Commit 2eca1ab

Browse files
committed
fixed undefined timeout value bug
1 parent dcbcbf0 commit 2eca1ab

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/extension/components/ReactPerfDevtool.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ let queries = {
2929
}`
3030
}
3131

32-
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
32+
const sleep = timeout => new Promise(resolve => setTimeout(resolve, timeout))
3333

3434
/**
3535
This is the main component that renders the table, containing information about
@@ -59,16 +59,6 @@ export class ReactPerfDevtool extends React.Component {
5959
}
6060
}
6161

62-
componentWillMount() {
63-
// When the devtool is launched first, measures may not be available.
64-
// Reload the window again to get the new measures and then display them.
65-
// Why ? We rely on the observer hook that the user has installed in his/her project.
66-
// This chrome plugin is just way to interpret the results derived from the observer's API
67-
if (store.length === 0) {
68-
this.reloadInspectedWindow()
69-
}
70-
}
71-
7262
componentDidMount() {
7363
// Show the loader while the measures get resolved.
7464
// showChart, when set to true, render the canvas required for Chart.js.
@@ -77,7 +67,7 @@ export class ReactPerfDevtool extends React.Component {
7767
// Defer the initialization of the extension until the application loads. Why ?
7868
// Because some of the applications are huge in size and may take a lot of time to load.
7969
// If the extension initialization process kicks-in before the app loads, we are trapped inside the error state.
80-
// With this, users can configure a timeout value for initialization of the extension using the observer hook
70+
// With this, users can configure a timeout value for initialization of the extension using the observer hook like this `registerObserver({ timeout: 4000 })`
8171
// Default value for the timeout is 2 sec.
8272

8373
// We need to resolve the promise after one sec. to make sure we have the updated __REACT_PERF_DEVTOOL_GLOBAL_STORE__ object otherwise we might end up with null
@@ -88,7 +78,7 @@ export class ReactPerfDevtool extends React.Component {
8878
return
8979
}
9080

91-
// This is also backward compatible with older versions of observer hook
81+
// This is also backward compatible with older versions of observer hook (for versions <= @3.0.8)
9282
this.timer = setInterval(
9383
() => this.getMeasuresLength(),
9484
timeout !== undefined ? JSON.parse(timeout) : 2000

0 commit comments

Comments
 (0)