* 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)
| 20803 | * @param {*} parentType element's parent's type. |
| 20804 | */ |
| 20805 | function validateExplicitKey(element, parentType) { |
| 20806 | if (!element._store || element._store.validated || element.key != null) { |
| 20807 | return; |
| 20808 | } |
| 20809 | element._store.validated = true; |
| 20810 | |
| 20811 | var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); |
| 20812 | if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { |
| 20813 | return; |
| 20814 | } |
| 20815 | ownerHasKeyUseWarning[currentComponentErrorInfo] = true; |
| 20816 | |
| 20817 | // Usually the current owner is the offender, but if it accepts children as a |
| 20818 | // property, it may be the creator of the child that's responsible for |
| 20819 | // assigning it a key. |
| 20820 | var childOwner = ''; |
| 20821 | if (element && element._owner && element._owner !== ReactCurrentOwner.current) { |
| 20822 | // Give the component that originally created this child. |
| 20823 | childOwner = ' It was passed a child from ' + getComponentName(element._owner) + '.'; |
| 20824 | } |
| 20825 | |
| 20826 | currentlyValidatingElement = element; |
| 20827 | { |
| 20828 | 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()); |
| 20829 | } |
| 20830 | currentlyValidatingElement = null; |
| 20831 | } |
| 20832 | |
| 20833 | /** |
| 20834 | * Ensure that every element either is passed in a static location, in an |
no test coverage detected