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

Bug: Nothing returned from renderer when returning undefined #20089

Closed
raRaRa opened this issue Oct 24, 2020 · 3 comments
Closed

Bug: Nothing returned from renderer when returning undefined #20089

raRaRa opened this issue Oct 24, 2020 · 3 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@raRaRa
Copy link

raRaRa commented Oct 24, 2020

React version: 17.0.0

Steps To Reproduce

  1. return undefined from a React component

Link to code example:
https://codesandbox.io/s/blazing-rain-jtdzy?file=/src/App.js

The current behavior

Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.

The expected behavior

Nothing should be rendered like in earlier React versions.

@raRaRa raRaRa added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Oct 24, 2020
@raRaRa
Copy link
Author

raRaRa commented Oct 24, 2020

The simple fix is of course to return null instead of return undefined, but I never saw this breaking change documented for React 17.0.0. Apologies if this is by design.

@kachkaev
Copy link

kachkaev commented Oct 24, 2020

This is intentional. See #19548, which was closed by #19550

Here is a blog post section on this behaviour: https://reactjs.org/blog/2020/08/10/react-v17-rc.html#consistent-errors-for-returning-undefined

Your codesandbox example would produce a warning in React 16 too.

@raRaRa
Copy link
Author

raRaRa commented Oct 24, 2020

@kachkaev Thanks. I've never noticed this warning during the development of my app in React 16, very odd. I'll close this issue since this is by design.

Thanks again.

@raRaRa raRaRa closed this as completed Oct 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

2 participants