MCPcopy Create free account
hub / github.com/Lobos/react-ui / shouldUpdateReactComponent

Function shouldUpdateReactComponent

docs/lib/react.js:17506–17520  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

17504 */
17505
17506function 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
17522module.exports = shouldUpdateReactComponent;
17523},{}],139:[function(_dereq_,module,exports){

Callers 1

react.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…