Skip to content

Commit

Permalink
Don't break on top-level non-numeric object keys
Browse files Browse the repository at this point in the history
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);
```
  • Loading branch information
sophiebits committed Mar 30, 2014
1 parent 999b4cf commit a89ed9b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/ReactDescriptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a89ed9b

Please sign in to comment.