MCPcopy Create free account
hub / github.com/Lucifier129/react-lite / getAddendaForKeyUse

Function getAddendaForKeyUse

examples/simple/react.js:9325–9355  ·  view source on GitHub ↗

* Shared warning and monitoring code for the key warnings. * * @internal * @param {string} messageType A key used for de-duping warnings. * @param {ReactElement} element Component that requires a key. * @param {*} parentType element's parent's type. * @returns {?object} A set of addenda to use

(messageType, element, parentType)

Source from the content-addressed store, hash-verified

9323 * if the warning has already been shown before (and shouldn't be shown again).
9324 */
9325function getAddendaForKeyUse(messageType, element, parentType) {
9326 var addendum = getDeclarationErrorAddendum();
9327 if (!addendum) {
9328 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
9329 if (parentName) {
9330 addendum = ' Check the top-level render call using <' + parentName + '>.';
9331 }
9332 }
9333
9334 var memoizer = ownerHasKeyUseWarning[messageType] || (ownerHasKeyUseWarning[messageType] = {});
9335 if (memoizer[addendum]) {
9336 return null;
9337 }
9338 memoizer[addendum] = true;
9339
9340 var addenda = {
9341 parentOrOwner: addendum,
9342 url: ' See https://fb.me/react-warning-keys for more information.',
9343 childOwner: null
9344 };
9345
9346 // Usually the current owner is the offender, but if it accepts children as a
9347 // property, it may be the creator of the child that's responsible for
9348 // assigning it a key.
9349 if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
9350 // Give the component that originally created this child.
9351 addenda.childOwner = ' It was passed a child from ' + element._owner.getName() + '.';
9352 }
9353
9354 return addenda;
9355}
9356
9357/**
9358 * Ensure that every element either is passed in a static location, in an

Callers 1

validateExplicitKeyFunction · 0.85

Calls 2

getNameMethod · 0.80

Tested by

no test coverage detected