* Warn if the element doesn't have an explicit key assigned to it. * This element is in an array. The array could grow and shrink or be * reordered. All children that haven't already been validated are required to * have a "key" property assigned to it. Error statuses are cached so a warning * w
(element, parentType)
| 18789 | * @param {*} parentType element's parent's type. |
| 18790 | */ |
| 18791 | function validateExplicitKey(element, parentType) { |
| 18792 | if (!element._store || element._store.validated || element.key != null) { |
| 18793 | return; |
| 18794 | } |
| 18795 | element._store.validated = true; |
| 18796 | |
| 18797 | var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); |
| 18798 | if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { |
| 18799 | return; |
| 18800 | } |
| 18801 | ownerHasKeyUseWarning[currentComponentErrorInfo] = true; |
| 18802 | |
| 18803 | // Usually the current owner is the offender, but if it accepts children as a |
| 18804 | // property, it may be the creator of the child that's responsible for |
| 18805 | // assigning it a key. |
| 18806 | var childOwner = ''; |
| 18807 | if (element && element._owner && element._owner !== ReactCurrentOwner.current) { |
| 18808 | // Give the component that originally created this child. |
| 18809 | childOwner = ' It was passed a child from ' + getComponentName(element._owner) + '.'; |
| 18810 | } |
| 18811 | |
| 18812 | currentlyValidatingElement = element; |
| 18813 | { |
| 18814 | warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.%s', currentComponentErrorInfo, childOwner, getStackAddendum()); |
| 18815 | } |
| 18816 | currentlyValidatingElement = null; |
| 18817 | } |
| 18818 | |
| 18819 | /** |
| 18820 | * Ensure that every element either is passed in a static location, in an |
no test coverage detected