Skip to content

Commit 43ed39e

Browse files
committed
Fix parsing for minified prod bundles
1 parent a8c4804 commit 43ed39e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

packages/react-debug-tools/src/ReactDebugHooks.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,15 @@ function parseHookName(functionName: void | string): string {
962962
if (!functionName) {
963963
return '';
964964
}
965-
let startIndex = functionName.lastIndexOf('.');
965+
let startIndex = functionName.lastIndexOf('[as ');
966+
967+
if (startIndex !== -1) {
968+
// Workaround for sourcemaps in Jest and Chrome.
969+
// In `node --enable-source-maps`, we don't see "Object.useHostTransitionStatus [as useFormStatus]" but "Object.useFormStatus"
970+
// "Object.useHostTransitionStatus [as useFormStatus]" -> "useFormStatus"
971+
return parseHookName(functionName.slice(startIndex + '[as '.length, -1));
972+
}
973+
startIndex = functionName.lastIndexOf('.');
966974
if (startIndex === -1) {
967975
startIndex = 0;
968976
} else {

packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegrationDOM-test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ describe('ReactHooksInspectionIntegration', () => {
3838
ReactDebugTools = require('react-debug-tools');
3939
});
4040

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

0 commit comments

Comments
 (0)