Return null as JSX element (no-null with React + TS)
See original GitHub issueIs necessary return null for a JSX Element
If use undefined TS return an error
Its return type 'Element | undefined' is not a valid JSX element.
Type 'undefined' is not assignable to type 'Element | null'.
Maybe enable null for a JSX return fix the bug.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How to return an empty jsx element from the render function in ...
I think just add { null } not null , in your section to show empty component.
Read more >Conditional Rendering - React
Use JavaScript operators like if or the conditional operator to create elements representing the current state, and let React update the UI to...
Read more >Documentation - TypeScript 2.0
TypeScript has two special types, Null and Undefined, that have the values null and undefined ... return a + b; // Produces value...
Read more >Optional chaining (?.) - JavaScript - MDN Web Docs - Mozilla
When used with function calls, it returns undefined if the given function ... For example, if obj.first is a Falsy value that's not...
Read more >its return type 'element | The AI Search Engine You Control
sindresorhus/eslint-plugin-unicornReturn null as JSX element (no-null with React + TS)#964. Created almost 2 years ago. 7. Is necessary return null for a ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Or possibly return an empty React.Fragment. I do that instead of using null.
We could maybe ignore reporting on
null
when in a JSX context or something.