@@ -133,10 +133,12 @@ scan({
133133});
134134```
135135
136- Or, if you prefer a more manual approach, use the ` withScan ` API:
136+ ## Examples
137+
138+ If you're digging into performance issues and prefer a more manual approach, use the ` withScan ` API:
137139
138140``` js
139- import { withScan } from ' react-scan' ;
141+ import { withScan , setOptions } from ' react-scan' ;
140142
141143const ExpensiveComponent = withScan (
142144 (props ) => {
@@ -146,6 +148,29 @@ const ExpensiveComponent = withScan(
146148);
147149```
148150
151+ You can also hook into internal lifecycle methods to for internal data or get a summary of component renders by calling ` getReport() ` :
152+
153+ ``` js
154+ import { setOptions , getReport } from ' react-scan' ;
155+
156+ setOptions ({
157+ onCommitStart () {},
158+ onRender (fiber , render ) {},
159+ onCommitFinish () {},
160+ onPaintStart (outline ) {},
161+ onPaintFinish (outline ) {},
162+ });
163+
164+ console .log (getReport ());
165+ // ^
166+ // {
167+ // "ExpensiveComponent": {
168+ // count: 100,
169+ // time: 400
170+ // }
171+ // }
172+ ```
173+
149174And voilà! You're ready to go.
150175
151176## Why React Scan?
@@ -208,21 +233,22 @@ We expect all contributors to abide by the terms of our [Code of Conduct](https:
208233
209234- [x] Scan only for unnecessary renders ("unstable" props)
210235- [x] Scan API (` withScan ` , ` scan ` )
211- - [ ] Don't show label if no reconciliation occurred ("client renders" in DevTools)
212- - [ ] Investigate ` __REACT_DEVTOOLS_TARGET_WINDOW__ `
236+ - [x] Cleanup config options
213237- [x] Chrome extension (h/t [ @biw ] ( https://github.com/biw ) )
238+ - [x] Mode to highlight long tasks
239+ - [x] Add context updates
240+ - [x] Expose primitives / internals for advanced use cases
241+ - [x] More explicit options override API (start log at certain area, stop log, etc.)
242+ - [x] Don't show label if no reconciliation occurred ("client renders" in DevTools)
243+ - [x] "global" counter using ` sessionStorage ` , aggregate count stats instead of immediate replacement
244+ - [x] Give a general report of the app's performance
245+ - [ ] UI for turning on/off options
214246- [ ] "PageSpeed insights" for React
215- - [x] Cleanup config options
216247- [ ] Offscreen canvas on worker thread
217248- [ ] React Native support
218- - [ ] "global" counter using ` sessionStorage ` , aggregate count stats instead of immediate replacement
219249- [ ] Name / explain the actual problem
220- - [x] More explicit options override API (start log at certain area, stop log, etc.)
221- - [x] Expose primitives / internals for advanced use cases
222- - [x] Add context updates
223250- [ ] Simple FPS counter
224251- [ ] Drag and select areas of the screen to scan
225- - [x] Mode to show on main thread blocking
226252- [ ] Add a funny mascot, like the [ "Stop I'm Changing" dude] ( https://www.youtube.com/shorts/FwOZdX7bDKI?app=desktop )
227253
228254## Acknowledgments
0 commit comments