From a89ed9b8dc7629b1896efcee86fe87b8be5afbee Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Sun, 30 Mar 2014 13:54:29 -0700 Subject: [PATCH] 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(
{{1:
, 2:
}}
, document.body); ``` --- src/core/ReactDescriptor.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/ReactDescriptor.js b/src/core/ReactDescriptor.js index ddbbebe72676..be5f8ddd76ce 100644 --- a/src/core/ReactDescriptor.js +++ b/src/core/ReactDescriptor.js @@ -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;