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); ```
Ben Alpert committed
Mar 30, 2014 at 13:54 UTC
a89ed9b8dc7629b1896efcee86fe87b8be5afbee
1 file changed
+5
src/core/ReactDescriptor.js
+5
@@ -95,6 +95,11 @@ function validateExplicitKey(component) {
95
* @param {ReactComponent} component Component that requires a key.
96
*/
97
function validatePropertyKey(name) {
98
+ // We can't provide friendly warnings for top level components.
99
+ if (!ReactCurrentOwner.current) {
100
+ return;
101
+ }
102
+
103
if (NUMERIC_PROPERTY_REGEX.test(name)) {
104
// Name of the component whose render method tried to pass children.
105
var currentName = ReactCurrentOwner.current.constructor.displayName;