mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
@@ -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>;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user