简体   繁体   中英

React - Overdoing it on “small components”

So I've been working with React for several years now and lately people in my team started doing stuff like this:

const InputContainer = (props) => {
    const className = props.className;
    return <div {...{ className }}>
        {props.children}
    </div>;
};

This is basically just writing a div with a class and rendering the children.

So now my question: In my idea this is just overkill and is not usefull. It is creating components just for the sole purpose of using html tags. What do you think?

Why would this be useful when I can just do

<div>
    <p> ....
</div>

in one component?

I'm not against using small components but in my mind, this is just too much and is bloating everything instead of just using html.

I think that it is overdoing. Are you sure it is not a joke? ;)
I am kidding, of course. Seriously, seems to me that it makes the code less readable and more difficult to maintain.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM