mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Don't break on top-level non-numeric object keys
Previously, this threw (in `__DEV__` only) in `ReactCurrentOwner.current.constructor.displayName` because `ReactCurrentOwner.current` is null:
```
React.renderComponent(<div>{{1: <div />, 2: <div />}}</div>, document.body);
```
This commit is contained in:
@@ -95,6 +95,11 @@ function validateExplicitKey(component) {
|
||||
* @param {ReactComponent} component Component that requires a key.
|
||||
*/
|
||||
function validatePropertyKey(name) {
|
||||
// We can't provide friendly warnings for top level components.
|
||||
if (!ReactCurrentOwner.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NUMERIC_PROPERTY_REGEX.test(name)) {
|
||||
// Name of the component whose render method tried to pass children.
|
||||
var currentName = ReactCurrentOwner.current.constructor.displayName;
|
||||
|
||||
Reference in New Issue
Block a user