(type, compare)
| 1535 | } |
| 1536 | |
| 1537 | function memo(type, compare) { |
| 1538 | { |
| 1539 | if (!isValidElementType(type)) { |
| 1540 | error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type); |
| 1541 | } |
| 1542 | } |
| 1543 | |
| 1544 | var elementType = { |
| 1545 | $$typeof: REACT_MEMO_TYPE, |
| 1546 | type: type, |
| 1547 | compare: compare === undefined ? null : compare |
| 1548 | }; |
| 1549 | |
| 1550 | { |
| 1551 | var ownName; |
| 1552 | Object.defineProperty(elementType, 'displayName', { |
| 1553 | enumerable: false, |
| 1554 | configurable: true, |
| 1555 | get: function () { |
| 1556 | return ownName; |
| 1557 | }, |
| 1558 | set: function (name) { |
| 1559 | ownName = name; // The inner component shouldn't inherit this display name in most cases, |
| 1560 | // because the component may be used elsewhere. |
| 1561 | // But it's nice for anonymous functions to inherit the name, |
| 1562 | // so that our component-stack generation logic will display their frames. |
| 1563 | // An anonymous function generally suggests a pattern like: |
| 1564 | // React.memo((props) => {...}); |
| 1565 | // This kind of inner function is not used elsewhere so the side effect is okay. |
| 1566 | |
| 1567 | if (!type.name && !type.displayName) { |
| 1568 | type.displayName = name; |
| 1569 | } |
| 1570 | } |
| 1571 | }); |
| 1572 | } |
| 1573 | |
| 1574 | return elementType; |
| 1575 | } |
| 1576 | |
| 1577 | function resolveDispatcher() { |
| 1578 | var dispatcher = ReactCurrentDispatcher.current; |
no test coverage detected
searching dependent graphs…