DevTools named hook parsing logic currently matches AST nodes using the original line number:
|
const name = getHookName( |
|
hook, |
|
hookSourceData.originalSourceAST, |
|
((hookSourceData.originalSourceCode: any): string), |
|
((originalSourceLineNumber: any): number), |
|
); |
But this may not be sufficient, as mentioned in comment #21641 (comment):
Are we assuming that a line number is sufficient to identify a hook call? Seems like that assumption breaks down in edge cases:
- Minified code (either without a source map, or a bundle built from pre-minified inputs) can have multiple hooks on one line.
- Some code might be authored with quirky formatting, i.e. not with a typical Prettier / ESLint setup.
DevTools named hook parsing logic currently matches AST nodes using the original line number:
react/packages/react-devtools-extensions/src/parseHookNames.js
Lines 341 to 346 in ed6c091
But this may not be sufficient, as mentioned in comment #21641 (comment):