Closed raRaRa closed 4 years ago
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.
This is intentional. See https://github.com/facebook/react/issues/19548, which was closed by https://github.com/facebook/react/pull/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.
@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.
React version: 17.0.0
Steps To Reproduce
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.