Skip to content

Commit

Permalink
Remove redundant if statement (facebook#21101)
Browse files Browse the repository at this point in the history
  • Loading branch information
E-Aho authored and acdlite committed Apr 13, 2021
1 parent c16d073 commit afbc053
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions packages/react-devtools-shared/src/hydration.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,23 +243,21 @@ export function dehydrate(
: data.constructor.name,
};

if (typeof data[Symbol.iterator]) {
// TRICKY
// Don't use [...spread] syntax for this purpose.
// This project uses @babel/plugin-transform-spread in "loose" mode which only works with Array values.
// Other types (e.g. typed arrays, Sets) will not spread correctly.
Array.from(data).forEach(
(item, i) =>
(unserializableValue[i] = dehydrate(
item,
cleaned,
unserializable,
path.concat([i]),
isPathAllowed,
isPathAllowedCheck ? 1 : level + 1,
)),
);
}
// TRICKY
// Don't use [...spread] syntax for this purpose.
// This project uses @babel/plugin-transform-spread in "loose" mode which only works with Array values.
// Other types (e.g. typed arrays, Sets) will not spread correctly.
Array.from(data).forEach(
(item, i) =>
(unserializableValue[i] = dehydrate(
item,
cleaned,
unserializable,
path.concat([i]),
isPathAllowed,
isPathAllowedCheck ? 1 : level + 1,
)),
);

unserializable.push(path);

Expand Down

0 comments on commit afbc053

Please sign in to comment.