* Given a `prevElement` and `nextElement`, determines if the existing * instance should be updated as opposed to being destroyed or replaced by a new * instance. Both arguments are elements. This ensures that this logic can * operate on stateless trees without any backing instance. * * @param {
(prevElement, nextElement)
| 17504 | */ |
| 17505 | |
| 17506 | function shouldUpdateReactComponent(prevElement, nextElement) { |
| 17507 | var prevEmpty = prevElement === null || prevElement === false; |
| 17508 | var nextEmpty = nextElement === null || nextElement === false; |
| 17509 | if (prevEmpty || nextEmpty) { |
| 17510 | return prevEmpty === nextEmpty; |
| 17511 | } |
| 17512 | |
| 17513 | var prevType = typeof prevElement; |
| 17514 | var nextType = typeof nextElement; |
| 17515 | if (prevType === 'string' || prevType === 'number') { |
| 17516 | return nextType === 'string' || nextType === 'number'; |
| 17517 | } else { |
| 17518 | return nextType === 'object' && prevElement.type === nextElement.type && prevElement.key === nextElement.key; |
| 17519 | } |
| 17520 | } |
| 17521 | |
| 17522 | module.exports = shouldUpdateReactComponent; |
| 17523 | },{}],139:[function(_dereq_,module,exports){ |
no outgoing calls
no test coverage detected
searching dependent graphs…