Skip to content
Merged
Changes from all 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
Introduce forward references in pretty printer
  • Loading branch information
Miguel Jimenez Esun committed Apr 25, 2018
commit 4490282a159c40eaf937976fd7b11a560d5a3d07
9 changes: 9 additions & 0 deletions packages/pretty-format/src/plugins/react_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {

const elementSymbol = Symbol.for('react.element');
const fragmentSymbol = Symbol.for('react.fragment');
const forwardRefSymbol = Symbol.for('react.forward_ref');

// Given element.props.children, or subtree during recursive traversal,
// return flattened array of children.
Expand All @@ -42,6 +43,14 @@ const getType = element => {
if (element.type === fragmentSymbol) {
return 'React.Fragment';
}
if (element.type === forwardRefSymbol) {
const functionName =
element.type.render.displayName || element.type.render.name || '';

return functionName !== ''
? 'ForwardRef(' + functionName + ')'
: 'ForwardRef';
}
return 'UNDEFINED';
};

Expand Down