(c, comparer)
| 9 | * @returns {import('./internal').FunctionComponent} |
| 10 | */ |
| 11 | export function memo(c, comparer) { |
| 12 | function shouldUpdate(nextProps) { |
| 13 | let ref = this.props.ref; |
| 14 | if (ref != nextProps.ref && ref) { |
| 15 | typeof ref == 'function' ? ref(null) : (ref.current = null); |
| 16 | } |
| 17 | |
| 18 | return comparer |
| 19 | ? !comparer(this.props, nextProps) || ref != nextProps.ref |
| 20 | : shallowDiffers(this.props, nextProps); |
| 21 | } |
| 22 | |
| 23 | function Memoed(props) { |
| 24 | this.shouldComponentUpdate = shouldUpdate; |
| 25 | return createElement(c, props); |
| 26 | } |
| 27 | Memoed.displayName = 'Memo(' + (c.displayName || c.name) + ')'; |
| 28 | Memoed._forwarded = Memoed.prototype.isReactComponent = true; |
| 29 | Memoed.type = c; |
| 30 | return Memoed; |
| 31 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…