admin管理员组

文章数量:1291041

I have installed Beautify to use it for my ReactJS code. However, it apparently does not properly beautify the HTML format in the file.

For example, it turns this:

into this:

Among all the options, which option should I use to fix this ?

I have installed Beautify to use it for my ReactJS code. However, it apparently does not properly beautify the HTML format in the file.

For example, it turns this:

into this:

Among all the options, which option should I use to fix this ?

Share Improve this question edited Dec 19, 2022 at 11:25 HedgeHog 25.2k5 gold badges17 silver badges41 bronze badges asked Oct 4, 2018 at 3:58 Jay JeongJay Jeong 1,0042 gold badges13 silver badges27 bronze badges 2
  • Use atom editor with prettier. atom.io/packages/prettier-atom – Dipak Commented Oct 4, 2018 at 4:03
  • Thanks! I don't know why, but as you remended Prettier works better for me. – Jay Jeong Commented Oct 4, 2018 at 4:22
Add a ment  | 

3 Answers 3

Reset to default 5

I used to have the same problem. Apparently beautify doesn't support JSX. I uninstalled and instead of it, I installed Prettier, it works great for me.

Hope I helped you.

Just change language mode javascript to javascript react [temporary]

VSCode Command: (Ctrl + KM)

Or Save file in .jsx format and change the settings.json file

"files.associations": {
    "*.jsx": "javascriptreact"
}

For those still struggling with this, there is also js-beautify's -X (--e4x) option which tells it to leave the XML content unchanged.

本文标签: htmlHow to use beautify for JavascriptReactStack Overflow