DEV Community

Discussion on: React Beginner Question Thread ⚛

Collapse
 
meligy profile image
Meligy • Edited

When starting and trying to make small pieces as much as possible, would you create a simple stateless component for something like an input and its label, etc.. instead of a long component managing 4 or so form fields, or quite often as long as the the component hasn't gone too crazy, splitting can be too much?

In simpler words... split all the way and create so many tiny stateless components, or this is often more writing for no benefit?

Collapse
 
dan_abramov profile image
Dan Abramov

I’m used to working with a designer who edits my JSX to add styling to it. So I’d first write larger components and then split them to a level that I think would be most comfortable for the designer. For example if I think that the input is complex enough that the designer would consider it a separate “entity” that should be consistently styled throughout the app, I’d extract it. If it’s a one-time thing, I’d only extract it if it helps me understand the code.