diff --git a/src/classic/types/ReactPropTypes.js b/src/classic/types/ReactPropTypes.js index e8f913f573..8e2e9f112a 100644 --- a/src/classic/types/ReactPropTypes.js +++ b/src/classic/types/ReactPropTypes.js @@ -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); diff --git a/src/classic/types/__tests__/ReactPropTypes-test.js b/src/classic/types/__tests__/ReactPropTypes-test.js index c3d9a49d8c..f87856491a 100644 --- a/src/classic/types/__tests__/ReactPropTypes-test.js +++ b/src/classic/types/__tests__/ReactPropTypes-test.js @@ -384,7 +384,9 @@ describe('ReactPropTypes', function() { k30: , k31: frag({k310: }), k32: 'Another string' - }) + }), + k4: null, + k5: undefined })); expect(console.warn.calls).toEqual([]); @@ -397,7 +399,9 @@ describe('ReactPropTypes', function() { k30: , k31: {k310: }, k32: 'Another string' - } + }, + k4: null, + k5: undefined }); });