* 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
(element, parentType)
| 3139 | * @param {*} parentType element's parent's type. |
| 3140 | */ |
| 3141 | function validateExplicitKey(element, parentType) { |
| 3142 | if (!element._store || element._store.validated || element.key != null) { |
| 3143 | return; |
| 3144 | } |
| 3145 | element._store.validated = true; |
| 3146 | |
| 3147 | var memoizer = ownerHasKeyUseWarning.uniqueKey || (ownerHasKeyUseWarning.uniqueKey = {}); |
| 3148 | |
| 3149 | var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); |
| 3150 | if (memoizer[currentComponentErrorInfo]) { |
| 3151 | return; |
| 3152 | } |
| 3153 | memoizer[currentComponentErrorInfo] = true; |
| 3154 | |
| 3155 | // Usually the current owner is the offender, but if it accepts children as a |
| 3156 | // property, it may be the creator of the child that's responsible for |
| 3157 | // assigning it a key. |
| 3158 | var childOwner = ''; |
| 3159 | if (element && element._owner && element._owner !== ReactCurrentOwner.current) { |
| 3160 | // Give the component that originally created this child. |
| 3161 | childOwner = ' It was passed a child from ' + element._owner.getName() + '.'; |
| 3162 | } |
| 3163 | |
| 3164 | process.env.NODE_ENV !== 'production' ? 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, ReactComponentTreeHook.getCurrentStackAddendum(element)) : void 0; |
| 3165 | } |
| 3166 | |
| 3167 | /** |
| 3168 | * Ensure that every element either is passed in a static location, in an |
no test coverage detected