Skip to content

Commit

Permalink
Fix parsing for minified prod bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Apr 3, 2024
1 parent a8c4804 commit 43ed39e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 9 additions & 1 deletion packages/react-debug-tools/src/ReactDebugHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,15 @@ function parseHookName(functionName: void | string): string {
if (!functionName) {
return '';
}
let startIndex = functionName.lastIndexOf('.');
let startIndex = functionName.lastIndexOf('[as ');

if (startIndex !== -1) {
// Workaround for sourcemaps in Jest and Chrome.
// In `node --enable-source-maps`, we don't see "Object.useHostTransitionStatus [as useFormStatus]" but "Object.useFormStatus"
// "Object.useHostTransitionStatus [as useFormStatus]" -> "useFormStatus"
return parseHookName(functionName.slice(startIndex + '[as '.length, -1));
}
startIndex = functionName.lastIndexOf('.');
if (startIndex === -1) {
startIndex = 0;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ describe('ReactHooksInspectionIntegration', () => {
ReactDebugTools = require('react-debug-tools');
});

// Gating production, non-source builds only for Jest.
// @gate source || build === "development"
it('should support useFormStatus hook', async () => {
function FormStatus() {
const status = ReactDOM.useFormStatus();
Expand Down

0 comments on commit 43ed39e

Please sign in to comment.