* 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)
| 10259 | * if the warning has already been shown before (and shouldn't be shown again). |
| 10260 | */ |
| 10261 | function 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 |
no test coverage detected
searching dependent graphs…