Parentheses 括号

  • 将多行的JSX标签写在 ()里. eslint: react/jsx-wrap-multilines

    1. // bad
    2. render() {
    3. return <MyComponent className="long body" foo="bar">
    4. <MyChild />
    5. </MyComponent>;
    6. }
    7. // good
    8. render() {
    9. return (
    10. <MyComponent className="long body" foo="bar">
    11. <MyChild />
    12. </MyComponent>
    13. );
    14. }
    15. // good, 单行可以不需要
    16. render() {
    17. const body = <div>hello</div>;
    18. return <MyComponent>{body}</MyComponent>;
    19. }