Skip to content

Commit 1cb8a16

Browse files
committed
Allow components to render undefined
1 parent bfa50f8 commit 1cb8a16

9 files changed

+285
-409
lines changed

packages/react-dom/src/__tests__/ReactDOMServerIntegrationElements-test.js

+28-24
Original file line numberDiff line numberDiff line change
@@ -924,33 +924,37 @@ describe('ReactDOMServerIntegration', () => {
924924
);
925925
});
926926

927-
describe('components that throw errors', function() {
928-
itThrowsWhenRendering(
929-
'a function returning undefined',
930-
async render => {
931-
const UndefinedComponent = () => undefined;
932-
await render(<UndefinedComponent />, 1);
933-
},
934-
'UndefinedComponent(...): Nothing was returned from render. ' +
935-
'This usually means a return statement is missing. Or, to ' +
936-
'render nothing, return null.',
937-
);
927+
describe('components that render nullish', function() {
928+
itRenders('a function returning null', async render => {
929+
const NullComponent = () => null;
930+
await render(<NullComponent />);
931+
});
938932

939-
itThrowsWhenRendering(
940-
'a class returning undefined',
941-
async render => {
942-
class UndefinedComponent extends React.Component {
943-
render() {
944-
return undefined;
945-
}
933+
itRenders('a class returning null', async render => {
934+
class NullComponent extends React.Component {
935+
render() {
936+
return null;
946937
}
947-
await render(<UndefinedComponent />, 1);
948-
},
949-
'UndefinedComponent(...): Nothing was returned from render. ' +
950-
'This usually means a return statement is missing. Or, to ' +
951-
'render nothing, return null.',
952-
);
938+
}
939+
await render(<NullComponent />);
940+
});
941+
942+
itRenders('a function returning undefined', async render => {
943+
const UndefinedComponent = () => undefined;
944+
await render(<UndefinedComponent />);
945+
});
946+
947+
itRenders('a class returning undefined', async render => {
948+
class UndefinedComponent extends React.Component {
949+
render() {
950+
return undefined;
951+
}
952+
}
953+
await render(<UndefinedComponent />);
954+
});
955+
});
953956

957+
describe('components that throw errors', function() {
954958
itThrowsWhenRendering(
955959
'a function returning an object',
956960
async render => {

0 commit comments

Comments
 (0)