DEV Community

Archana Sharma
Archana Sharma

Posted on

React return 'null' vs return 'false'. Which is better and why?

I have read some articles about stopping using the return 'null' as well as using 'null' over 'false'. Please tell me what we can use and why. Also, their importance and usage.

I have followed two articles and both support different things. But how does React work in both cases, please explain in detail.

stop using null

supporting return null

Please suggest.

Top comments (1)

Collapse
 
leandro_nnz profile image
Leandro Nuñez

return false makes react to unmount the component. David is wrong. Even the official documentation tells you to return null when you don't want to render anything.