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

Function getAddendaForKeyUse

docs/lib/react.js:10261–10291  ·  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

10259 * if the warning has already been shown before (and shouldn't be shown again).
10260 */
10261function getAddendaForKeyUse(messageType, element, parentType) {
10262 var addendum = getDeclarationErrorAddendum();
10263 if (!addendum) {
10264 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
10265 if (parentName) {
10266 addendum = ' Check the top-level render call using <' + parentName + '>.';
10267 }
10268 }
10269
10270 var memoizer = ownerHasKeyUseWarning[messageType] || (ownerHasKeyUseWarning[messageType] = {});
10271 if (memoizer[addendum]) {
10272 return null;
10273 }
10274 memoizer[addendum] = true;
10275
10276 var addenda = {
10277 parentOrOwner: addendum,
10278 url: ' See https://fb.me/react-warning-keys for more information.',
10279 childOwner: null
10280 };
10281
10282 // Usually the current owner is the offender, but if it accepts children as a
10283 // property, it may be the creator of the child that's responsible for
10284 // assigning it a key.
10285 if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
10286 // Give the component that originally created this child.
10287 addenda.childOwner = ' It was passed a child from ' + element._owner.getName() + '.';
10288 }
10289
10290 return addenda;
10291}
10292
10293/**
10294 * Ensure that every element either is passed in a static location, in an

Callers 1

validateExplicitKeyFunction · 0.85

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…