Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow components to render undefined #21869

Merged
merged 1 commit into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Loading