Skip to content

Commit

Permalink
Code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kim committed May 1, 2018
1 parent 22216a4 commit e02ca82
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/pretty-format/src/__tests__/react.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ test('supports forwardRef with a child', () => {
}

expect(
// $FlowFixMe - https://github.com/facebook/flow/issues/6103
formatElement(React.createElement(React.forwardRef(Cat), null, 'mouse')),
).toEqual('<ForwardRef(Cat)>\n mouse\n</ForwardRef(Cat)>');
});
Expand Down
13 changes: 6 additions & 7 deletions packages/pretty-format/src/plugins/react_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,16 @@ const getChildren = (arg, children = []) => {
};

const getType = element => {
if (typeof element.type === 'string') {
return element.type;
const type = element.type;
if (typeof type === 'string') {
return type;
}
if (typeof element.type === 'function') {
return element.type.displayName || element.type.name || 'Unknown';
if (typeof type === 'function') {
return type.displayName || type.name || 'Unknown';
}
if (element.type === fragmentSymbol) {
if (type === fragmentSymbol) {
return 'React.Fragment';
}

const type = element.type;
if (typeof type === 'object' && type !== null) {
if (type.$$typeof === providerSymbol) {
return 'Context.Provider';
Expand Down

0 comments on commit e02ca82

Please sign in to comment.