Skip to content

Commit 56fcc69

Browse files
committed
Use same pattern in custom snapshot serializers
1 parent ee699c0 commit 56fcc69

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/react-devtools-shared/src/__tests__/treeContextStateSerializer.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import {printStore} from 'react-devtools-shared/src/devtools/utils';
22

33
// test() is part of Jest's serializer API
44
export function test(maybeState) {
5+
if (maybeState === null || typeof maybeState !== 'object') {
6+
return false;
7+
}
8+
59
const hasOwnProperty = Object.prototype.hasOwnProperty.bind(maybeState);
610
// Duck typing at its finest.
711
return (
8-
maybeState !== null &&
9-
typeof maybeState === 'object' &&
1012
hasOwnProperty('inspectedElementID') &&
1113
hasOwnProperty('ownerFlatTree') &&
1214
hasOwnProperty('ownerSubtreeLeafElementID')

0 commit comments

Comments
 (0)