简体   繁体   中英

Prettier: Remove `return` of an arrow function, in JavaScript?

I would like to have prettier removes the unnecessary return statement.
For the next code example:

const Component = ({ children }) => {
    return (
        <div>
            {children}
        </div>
    );
};

I would like prettier removes the return statement, and turn it into:

const Component = ({ children }) => <div>{children}</div>;

Is it possible?

Olá Tente desta forma por favor. Pois acredito que não sejam necessárias as chaves {} dentro dos parenteses () e nem o return.

const Component = (children) => ( {children} )

};

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