Skip to content

Commit

Permalink
fix: check bigint in serializeToString and change it to string
Browse files Browse the repository at this point in the history
  • Loading branch information
nutboltu committed Jan 31, 2020
1 parent 1c85c8e commit 9fc9f76
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
11 changes: 2 additions & 9 deletions packages/react-devtools-shared/src/backend/legacy/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ import {
ElementTypeHostComponent,
ElementTypeOtherOrUnknown,
} from 'react-devtools-shared/src/types';
import {
getUID,
utfEncodeString,
printOperationsArray,
formatDataForPreview,
} from '../../utils';
import {getUID, utfEncodeString, printOperationsArray} from '../../utils';
import {cleanForBridge, copyToClipboard, copyWithSet} from '../utils';
import {getDisplayName, getInObject} from 'react-devtools-shared/src/utils';
import {
Expand Down Expand Up @@ -679,9 +674,7 @@ export function attach(
function copyElementPath(id: number, path: Array<string | number>): void {
const inspectedElement = inspectElementRaw(id);
if (inspectedElement !== null) {
copyToClipboard(
formatDataForPreview(getInObject(inspectedElement, path), true),
);
copyToClipboard(getInObject(inspectedElement, path));
}
}

Expand Down
10 changes: 3 additions & 7 deletions packages/react-devtools-shared/src/backend/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
} from 'react-devtools-shared/src/utils';
import {sessionStorageGetItem} from 'react-devtools-shared/src/storage';
import {cleanForBridge, copyToClipboard, copyWithSet} from './utils';
import {formatDataForPreview} from '../utils';
import {
__DEBUG__,
SESSION_STORAGE_RELOAD_AND_PROFILE_KEY,
Expand Down Expand Up @@ -2532,12 +2531,9 @@ export function attach(

if (isCurrent) {
copyToClipboard(
formatDataForPreview(
getInObject(
((mostRecentlyInspectedElement: any): InspectedElement),
path,
),
true,
getInObject(
((mostRecentlyInspectedElement: any): InspectedElement),
path,
),
);
}
Expand Down
4 changes: 4 additions & 0 deletions packages/react-devtools-shared/src/backend/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ export function serializeToString(data: any): string {
}
cache.add(value);
}
// $FlowFixMe
if (typeof value === 'bigint') {
return value.toString() + 'n';
}
return value;
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const immutable = Immutable.fromJS({
xyz: 1,
},
});
// eslint-disable-next-line no-undef
const bigInt = BigInt(123);
// $FlowFixMe
const bigInt = BigInt(123); // eslint-disable-line no-undef

export default function UnserializableProps() {
return (
Expand Down

0 comments on commit 9fc9f76

Please sign in to comment.