Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make serializable data in react-devtools #17233

Merged
merged 4 commits into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/react-devtools-shared/src/devtools/views/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export function getMetaValueLabel(data: Object): string | null {
case 'date':
case 'symbol':
return name;
case 'bigint':
return `${name}n`;
case 'iterator':
return `${name}(…)`;
case 'array_buffer':
Expand Down
11 changes: 11 additions & 0 deletions packages/react-devtools-shared/src/hydration.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const LEVEL_THRESHOLD = 2;
type PropType =
| 'array'
| 'array_buffer'
| 'bigint'
| 'boolean'
| 'data_view'
| 'date'
Expand Down Expand Up @@ -107,6 +108,8 @@ function getDataType(data: Object): PropType {

const type = typeof data;
switch (type) {
case 'bigint':
return 'bigint';
case 'boolean':
return 'boolean';
case 'function':
Expand Down Expand Up @@ -231,6 +234,14 @@ export function dehydrate(
case 'string':
return data.length <= 500 ? data : data.slice(0, 500) + '...';

case 'bigint':
cleaned.push(path);
return {
inspectable: false,
name: data.toString(),
type,
};

case 'symbol':
cleaned.push(path);
return {
Expand Down