Skip to content

Commit 9fc9f76

Browse files
committed
fix: check bigint in serializeToString and change it to string
1 parent 1c85c8e commit 9fc9f76

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

packages/react-devtools-shared/src/backend/legacy/renderer.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ import {
1414
ElementTypeHostComponent,
1515
ElementTypeOtherOrUnknown,
1616
} from 'react-devtools-shared/src/types';
17-
import {
18-
getUID,
19-
utfEncodeString,
20-
printOperationsArray,
21-
formatDataForPreview,
22-
} from '../../utils';
17+
import {getUID, utfEncodeString, printOperationsArray} from '../../utils';
2318
import {cleanForBridge, copyToClipboard, copyWithSet} from '../utils';
2419
import {getDisplayName, getInObject} from 'react-devtools-shared/src/utils';
2520
import {
@@ -679,9 +674,7 @@ export function attach(
679674
function copyElementPath(id: number, path: Array<string | number>): void {
680675
const inspectedElement = inspectElementRaw(id);
681676
if (inspectedElement !== null) {
682-
copyToClipboard(
683-
formatDataForPreview(getInObject(inspectedElement, path), true),
684-
);
677+
copyToClipboard(getInObject(inspectedElement, path));
685678
}
686679
}
687680

packages/react-devtools-shared/src/backend/renderer.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import {
3535
} from 'react-devtools-shared/src/utils';
3636
import {sessionStorageGetItem} from 'react-devtools-shared/src/storage';
3737
import {cleanForBridge, copyToClipboard, copyWithSet} from './utils';
38-
import {formatDataForPreview} from '../utils';
3938
import {
4039
__DEBUG__,
4140
SESSION_STORAGE_RELOAD_AND_PROFILE_KEY,
@@ -2532,12 +2531,9 @@ export function attach(
25322531

25332532
if (isCurrent) {
25342533
copyToClipboard(
2535-
formatDataForPreview(
2536-
getInObject(
2537-
((mostRecentlyInspectedElement: any): InspectedElement),
2538-
path,
2539-
),
2540-
true,
2534+
getInObject(
2535+
((mostRecentlyInspectedElement: any): InspectedElement),
2536+
path,
25412537
),
25422538
);
25432539
}

packages/react-devtools-shared/src/backend/utils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ export function serializeToString(data: any): string {
8181
}
8282
cache.add(value);
8383
}
84+
// $FlowFixMe
85+
if (typeof value === 'bigint') {
86+
return value.toString() + 'n';
87+
}
8488
return value;
8589
});
8690
}

packages/react-devtools-shell/src/app/InspectableElements/UnserializableProps.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const immutable = Immutable.fromJS({
3131
xyz: 1,
3232
},
3333
});
34-
// eslint-disable-next-line no-undef
35-
const bigInt = BigInt(123);
34+
// $FlowFixMe
35+
const bigInt = BigInt(123); // eslint-disable-line no-undef
3636

3737
export default function UnserializableProps() {
3838
return (

0 commit comments

Comments
 (0)