react-perf-devtool
Advanced tools
Comparing version 3.0.3-beta3 to 3.0.4-beta0
{ | ||
"name": "react-perf-devtool", | ||
"version": "3.0.3-beta3", | ||
"version": "3.0.4-beta0", | ||
"description": "A devtool for inspecting the performance of React Components", | ||
@@ -5,0 +5,0 @@ "main": "src/npm/index.js", |
# React Performance Devtool | ||
[](https://travis-ci.org/nitin42/react-perf-devtool) | ||
@@ -11,3 +12,3 @@  | ||
<p align="center"> | ||
<img src="./art/RPLogo.png" height="200" width="200"> | ||
<img src="https://i.gyazo.com/332f573872d396e4f665d58e491a8ccd.png"> | ||
</p> | ||
@@ -300,2 +301,24 @@ | ||
**components** | ||
You can also inspect the performance of specific components using options through **`components`** property. | ||
<img src="http://g.recordit.co/sAQGSOrCA7.gif"> | ||
Example - | ||
```js | ||
var options = { | ||
shouldLog: true, | ||
port: 3000, | ||
components: ['App', 'Main'] // Assuming you've these components in your project | ||
} | ||
function callback(measures) { | ||
// do something with measures | ||
} | ||
registerObserver(options, callback) | ||
``` | ||
## Description | ||
@@ -302,0 +325,0 @@ |
@@ -34,3 +34,3 @@ var getReactPerformanceData = require('../shared/parse') | ||
params = params || {} | ||
var { shouldLog, port, components } = params | ||
var { shouldLog, port, components, webService } = params | ||
var observer = new window.PerformanceObserver(list => { | ||
@@ -51,2 +51,23 @@ var measures = generateDataFromMeasures( | ||
if (webService) { | ||
var storage = window.localStorage | ||
var KEY = '__REACT_PERF_DEVTOOL_GLOBAL_STORE__' | ||
if (storage.getItem(KEY) === null || storage.getItem(KEY) === undefined) { | ||
storage.setItem(KEY, { | ||
measures, | ||
length: list.getEntries().length, | ||
rawMeasures: list.getEntries() | ||
}) | ||
} else if (storage.getItem(KEY) !== null) { | ||
storage.removeItem(KEY) | ||
// New measures | ||
storage.setItem(KEY, { | ||
measures, | ||
length: list.getEntries().length, | ||
rawMeasures: list.getEntries() | ||
}) | ||
} | ||
} | ||
// For logging to console | ||
@@ -94,3 +115,3 @@ if (shouldLog) { | ||
componentDidUpdate, | ||
componentWillUnmount, | ||
componentWillUnmount | ||
}) => { | ||
@@ -114,3 +135,3 @@ // The time is in millisecond (ms) | ||
componentDidUpdate, | ||
componentWillUnmount, | ||
componentWillUnmount | ||
} | ||
@@ -117,0 +138,0 @@ |
59888
893
408