DEV Community

Discussion on: React Single File Components Are Here

Collapse
 
alexeychikk profile image
Alex Zinkevych

Please, don't return an array/fragment as a component's render result unless it conditionally resolves into one element. It really harms reusability.

Collapse
 
swyx profile image
swyx

I don't understand. I didn't propose that at all?

Collapse
 
alexeychikk profile image
Alex Zinkevych • Edited

Your Success component returns an array of elements. Reusing it in different components with different css layout would require wrapping it each time with something like <div className="foo-bar"><Success /></div>.
Instead your <Success> component should return a div and optionally accept className prop.

Thread Thread
 
swyx profile image
swyx

use a Fragment?

Thread Thread
 
alexeychikk profile image
Alex Zinkevych

Fragment is not an element, it doesn't accept className.