You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to install the Chrome extension, follow the guide [here](https://github.com/aidenybai/react-scan/blob/main/BROWSER_EXTENSION_GUIDE.md), or React Native support, see [here](https://github.com/aidenybai/react-scan/pull/23).
119
-
120
-
## API Reference
121
-
122
-
If you need a programmatic API to debug further, install via NPM instead:
log:true, // logs render info to console (default: false)
138
-
});
139
-
}
140
-
```
63
+
### CLI
141
64
142
-
> Looking for [React Native](https://github.com/aidenybai/react-scan/pull/23)?
143
-
144
-
If you don't have a local version of the site, you can use the CLI. This will spin up an isolated browser instance which you can interact or use React Scan with.
65
+
If you don't have a local version of the site or you want to test a React app remotely, you can use the CLI. This will spin up an isolated browser instance which you can interact or use React Scan with.
145
66
146
67
```bash
147
68
npx react-scan@latest http://localhost:3000
@@ -160,6 +81,14 @@ You can add it to your existing dev process as well. Here's an example for Next.
160
81
}
161
82
```
162
83
84
+
### Browser Extension
85
+
86
+
If you want to install the Chrome extension, follow the guide [here](https://github.com/aidenybai/react-scan/blob/main/BROWSER_EXTENSION_GUIDE.md).
87
+
88
+
### React Native
89
+
90
+
See [discussion](https://github.com/aidenybai/react-scan/pull/23)
91
+
163
92
## API Reference
164
93
165
94
<details>
@@ -178,113 +107,65 @@ export interface Options {
178
107
* @defaulttrue
179
108
*/
180
109
enabled?:boolean;
181
-
/**
182
-
* Include children of a component applied with withScan
183
-
*
184
-
* @defaulttrue
185
-
*/
186
-
includeChildren?:boolean;
187
110
188
111
/**
189
-
* Enable/disable geiger sound
112
+
* Force React Scan to run in production (not recommended)
190
113
*
191
-
* @defaulttrue
114
+
* @defaultfalse
192
115
*/
193
-
playSound?:boolean;
194
-
116
+
dangerouslyForceRunInProduction?:boolean;
195
117
/**
196
118
* Log renders to the console
197
119
*
120
+
* WARNING: This can add significant overhead when the app re-renders frequently
121
+
*
198
122
* @defaultfalse
199
123
*/
200
124
log?:boolean;
201
125
202
126
/**
203
127
* Show toolbar bar
204
128
*
129
+
* If you set this to true, and set {@linkenabled} to false, the toolbar will still show, but scanning will be disabled.
130
+
*
205
131
* @defaulttrue
206
132
*/
207
133
showToolbar?:boolean;
208
134
209
-
/**
210
-
* Render count threshold, only show
211
-
* when a component renders more than this
212
-
*
213
-
* @default0
214
-
*/
215
-
renderCountThreshold?:number;
216
-
217
-
/**
218
-
* Clear aggregated fibers after this time in milliseconds
219
-
*
220
-
* @default5000
221
-
*/
222
-
resetCountTimeout?:number;
223
-
224
-
/**
225
-
* Maximum number of renders for red indicator
226
-
*
227
-
* @default20
228
-
* @deprecated
229
-
*/
230
-
maxRenders?:number;
231
-
232
-
/**
233
-
* Report data to getReport()
234
-
*
235
-
* @defaultfalse
236
-
*/
237
-
report?:boolean;
238
-
239
-
/**
240
-
* Always show labels
241
-
*
242
-
* @defaultfalse
243
-
*/
244
-
alwaysShowLabels?:boolean;
245
-
246
135
/**
247
136
* Animation speed
248
137
*
249
138
* @default"fast"
250
139
*/
251
-
animationSpeed?:'slow'|'fast'|'off';
252
-
253
-
/**
254
-
* Smoothly animate the re-render outline when the element moves
255
-
*
256
-
* @defaulttrue
257
-
*/
258
-
smoothlyAnimateOutlines?:boolean;
140
+
animationSpeed?:"slow"|"fast"|"off";
259
141
260
142
/**
261
143
* Track unnecessary renders, and mark their outlines gray when detected
262
144
*
263
-
* An unnecessary render is defined as a component re-rendering with no change to the component's corresponding dom subtree (e.g. a component re-rendered, but nothing in the components UI did not change)
145
+
* An unnecessary render is defined as the component re-rendering with no change to the component's
146
+
* corresponding dom subtree
264
147
*
265
-
* @defaulttrue
148
+
* @defaultfalse
266
149
* @warning tracking unnecessary renders can add meaningful overhead to react-scan
-`scan(options: Options)`: Imperative API to start scanning
281
164
-`useScan(options: Options)`: Hook API to start scanning
282
-
-`withScan(Component, options: Options)`: Whitelist a specific component, do not scan other components
283
165
-`getReport()`: Get a report of all the renders
284
166
-`setOptions(options: Options): void`: Set options at runtime
285
167
-`getOptions()`: Get the current options
286
168
-`onRender(Component, onRender: (fiber: Fiber, render: Render) => void)`: Hook into a specific component's renders
287
-
-`getRenderInfo(Component)`: Get the render info for a specific component
288
169
289
170
## Why React Scan?
290
171
@@ -297,7 +178,7 @@ However, this makes it easy to accidentally cause unnecessary renders, making th
297
178
This often comes down to props that update in reference, like callbacks or object values. For example, the `onClick` function and `style` object are re-created on every render, causing `ExpensiveComponent` to slow down the app:
React Scan helps you identify these issues by automatically detecting and highlighting renders that cause performance issues. Now, instead of guessing, you can see exactly which components you need to fix.
@@ -320,17 +201,7 @@ Also, some personal complaints about React Devtools' highlight feature:
320
201
- No programmatic API
321
202
- It's stuck in a chrome extension, I want to run it anywhere on the web
322
203
- It looks subjectively ugly (lines look fuzzy, feels sluggish)
323
-
- I'm more ambitious with react-scan (see our roadmap)
324
-
325
-
**Q: React Native wen?**
326
-
327
-
Soon :)
328
-
329
-
**Q: Browser Extension wen?**
330
-
331
-
The browser extension is available for Chrome, Firefox, and Brave, but it's awaiting approval from browser extension stores.
332
-
333
-
In the meanwhile, you can install it manually by following the instructions in [BROWSER_EXTENSION_GUIDE.md](BROWSER_EXTENSION_GUIDE.md).
204
+
- I'm more ambitious with react-scan
334
205
335
206
## Resources & Contributing Back
336
207
@@ -346,35 +217,6 @@ We expect all contributors to abide by the terms of our [Code of Conduct](https:
346
217
347
218
[**→ Start contributing on GitHub**](https://github.com/aidenybai/react-scan/blob/main/.github/CONTRIBUTING.md)
348
219
349
-
## Roadmap
350
-
351
-
-[x] Scan only for unnecessary renders ("unstable" props)
-[x] Expose primitives / internals for advanced use cases
358
-
-[x] More explicit options override API (start log at certain area, stop log, etc.)
359
-
-[x] Don't show label if no reconciliation occurred ("client renders" in DevTools)
360
-
-[x] "global" counter using `sessionStorage`, aggregate count stats instead of immediate replacement
361
-
-[x] Give a general report of the app's performance
362
-
-[x] Select areas of the screen to scan
363
-
-[x] Report should include all renders
364
-
-[x] heatmap decay (stacked renders will be more intense)
365
-
-[x] Investigate components (UI allowlist)
366
-
-[ ] Offscreen canvas on worker thread
367
-
-[ ] UI for turning on/off options
368
-
-[ ] “PageSpeed insights” for React
369
-
-[ ] CLI
370
-
-[ ] React Native support
371
-
-[ ] Cleanup API reference
372
-
-[ ] Name / explain the actual problem, docs
373
-
-[ ] Simple FPS counter
374
-
-[ ][Runtime version guarding](https://github.com/lahmatiy/react-render-tracker/blob/229ad0e9c28853615300724d5dc86c140f250f60/src/publisher/react-integration/utils/getInternalReactConstants.ts#L28)
375
-
-[ ] React as peer dependency (lock version to range)
376
-
-[ ] Add a funny mascot, like the ["Stop I'm Changing" dude](https://www.youtube.com/shorts/FwOZdX7bDKI?app=desktop)
377
-
378
220
## Acknowledgments
379
221
380
222
React Scan takes inspiration from the following projects:
0 commit comments