mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Allow null and undefined values in non-frag object passed to PropTypes.node
This commit is contained in:
@@ -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
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user