-
Notifications
You must be signed in to change notification settings - Fork 48.8k
Added performance timings to DevTools named hooks parsing #22173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added performance timings to DevTools named hooks parsing #22173
Conversation
|
||
let potentialReactHookASTNode = null; | ||
if (originalSourceColumnNumber === 0) { | ||
// This most likely indicates a source map type like 'cheap-module-source-map' | ||
// that intentionally drops column numbers for compilation speed in DEV builds. | ||
// In this case, we can assume there's probably only one hook per line (true in most cases) | ||
// and just fail if we find more than one match. | ||
const matchingNodes = hooksFromAST.filter(node => { | ||
const matchingNodes = hooksFromAST.filter((node, index) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is index being used anywhere here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. It was initially (when I added some logs) and I just forgot to remove it. Will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did we have a lint rule for unused declarations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, generally, but I guess it doesn't apply to function params.
@@ -152,12 +169,13 @@ export function getHookName( | |||
potentialReactHookASTNode = matchingNodes[0]; | |||
} | |||
} else { | |||
potentialReactHookASTNode = hooksFromAST.find(node => { | |||
potentialReactHookASTNode = hooksFromAST.find((node, index) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto here
This can be turned on or off (statically) via a new __PERFORMANCE_PROFILE__ flag in react-devtools-shared/src/constants. For now, it's disabled, but it's useful to turn on when performance profiling.
59ca485
to
84d013b
Compare
This can be turned on or off (statically) via a new
__PERFORMANCE_PROFILE__
flag inreact-devtools-shared/src/constants
. For now, it's disabled, but it's useful to turn on when performance profiling.When enabled, the flag will generate measures like: