Visual studio code changes format (React-JSX)

2019-01-22 13:09发布

I've the following snippet in my index.js

class App extends Component {
render() {
    return ( <div style = { styles.app } >
        Welcome to React!
        </div>
    )
}

}
The code works, but every time I save (ctrl+s) visual studio format the jsx like that:

class App extends Component {
render() {
    return ( < div style = { styles.app } >
        Welcome to React!
        <
        /div>
    )
}

}

How can I solve this? thanks

7条回答
做自己的国王
2楼-- · 2019-01-22 13:56

You can install an extension like react-beautify that helps you format your jsx code.

It is found here

This extension wraps prettydiff/esformatter to format your javascript, JSX, typescript, TSX file.

查看更多
登录 后发表回答