Don't blow up on missing _store in element validation
Seems better to fail gracefully, especially now that we support inlining. If people do this by accident we can figure out how to add a helpful warning instead. Fixes #3285.
Ben Alpert committed
Sep 25, 2015 at 13:02 UTC
e352475ddc4c8f49fb5d3d9e1e29dcc20c0be0ad
2 files changed
+17
-1
src/isomorphic/classic/element/ReactElementValidator.js
+1
-1
@@ -57,7 +57,7 @@ var loggedTypeFailures = {};
57
* @param {*} parentType element's parent's type.
58
*/
59
function validateExplicitKey(element, parentType) {
60
- if (element._store.validated || element.key != null) {
60
+ if (!element._store || element._store.validated || element.key != null) {
61
return;
62
}
63
element._store.validated = true;
src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js
+16
@@ -467,4 +467,20 @@ describe('ReactElementValidator', function() {
467
}
468
});
469
470
+ it('does not blow up with inlined children', function() {
471
+ // We don't suggest this since it silences all sorts of warnings, but we
472
+ // shouldn't blow up either.
473
+
474
+ var child = {
475
+ $$typeof: (<div />).$$typeof,
476
+ type: 'span',
477
+ key: null,
478
+ ref: null,
479
+ props: {},
480
+ _owner: null,
481
+ };
482
+
483
+ void <div>{[child]}</div>;
484
+ });
485
+
486
});