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.
This commit is contained in:
Ben Alpert
2015-09-25 13:09:03 -07:00
parent 530b6332ed
commit e352475ddc
2 changed files with 17 additions and 1 deletions
@@ -57,7 +57,7 @@ var loggedTypeFailures = {};
* @param {*} parentType element's parent's type.
*/
function validateExplicitKey(element, parentType) {
if (element._store.validated || element.key != null) {
if (!element._store || element._store.validated || element.key != null) {
return;
}
element._store.validated = true;
@@ -467,4 +467,20 @@ describe('ReactElementValidator', function() {
}
});
it('does not blow up with inlined children', function() {
// We don't suggest this since it silences all sorts of warnings, but we
// shouldn't blow up either.
var child = {
$$typeof: (<div />).$$typeof,
type: 'span',
key: null,
ref: null,
props: {},
_owner: null,
};
void <div>{[child]}</div>;
});
});