Allow null and undefined values in non-frag object passed to PropTypes.node

This commit is contained in:
Paul O’Shannessy
2015-03-05 15:14:10 -08:00
parent fa8961118a
commit 0e797dffe4
2 changed files with 8 additions and 3 deletions
+2 -1
View File
@@ -292,6 +292,7 @@ function isNode(propValue) {
switch (typeof propValue) {
case 'number':
case 'string':
case 'undefined':
return true;
case 'boolean':
return !propValue;
@@ -299,7 +300,7 @@ function isNode(propValue) {
if (Array.isArray(propValue)) {
return propValue.every(isNode);
}
if (ReactElement.isValidElement(propValue)) {
if (propValue === null || ReactElement.isValidElement(propValue)) {
return true;
}
propValue = ReactFragment.extractIfFragment(propValue);
@@ -384,7 +384,9 @@ describe('ReactPropTypes', function() {
k30: <MyComponent />,
k31: frag({k310: <a />}),
k32: 'Another string'
})
}),
k4: null,
k5: undefined
}));
expect(console.warn.calls).toEqual([]);
@@ -397,7 +399,9 @@ describe('ReactPropTypes', function() {
k30: <MyComponent />,
k31: {k310: <a />},
k32: 'Another string'
}
},
k4: null,
k5: undefined
});
});