Skip to content

Commit

Permalink
Allow components to render undefined (#21869)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Jul 13, 2021
1 parent 87b67d3 commit 14bac61
Show file tree
Hide file tree
Showing 10 changed files with 286 additions and 416 deletions.
Expand Up @@ -924,33 +924,37 @@ describe('ReactDOMServerIntegration', () => {
);
});

describe('components that throw errors', function() {
itThrowsWhenRendering(
'a function returning undefined',
async render => {
const UndefinedComponent = () => undefined;
await render(<UndefinedComponent />, 1);
},
'UndefinedComponent(...): Nothing was returned from render. ' +
'This usually means a return statement is missing. Or, to ' +
'render nothing, return null.',
);
describe('components that render nullish', function() {
itRenders('a function returning null', async render => {
const NullComponent = () => null;
await render(<NullComponent />);
});

itThrowsWhenRendering(
'a class returning undefined',
async render => {
class UndefinedComponent extends React.Component {
render() {
return undefined;
}
itRenders('a class returning null', async render => {
class NullComponent extends React.Component {
render() {
return null;
}
await render(<UndefinedComponent />, 1);
},
'UndefinedComponent(...): Nothing was returned from render. ' +
'This usually means a return statement is missing. Or, to ' +
'render nothing, return null.',
);
}
await render(<NullComponent />);
});

itRenders('a function returning undefined', async render => {
const UndefinedComponent = () => undefined;
await render(<UndefinedComponent />);
});

itRenders('a class returning undefined', async render => {
class UndefinedComponent extends React.Component {
render() {
return undefined;
}
}
await render(<UndefinedComponent />);
});
});

describe('components that throw errors', function() {
itThrowsWhenRendering(
'a function returning an object',
async render => {
Expand Down

0 comments on commit 14bac61

Please sign in to comment.