Install these Atom Packages for React
- Start Atom, open the Settings view, and click Install.
- Install prettier-atom, if you have not aleady done so. This package beautifies JSX code.
- Install language-babel. This package handles auto-indent, etc., for JSX code.
You can also install this package from the command line (Command Prompt or Terminal), using Atom’s package manager:
apm install language-babel
Configure these Atom Packages for React
- Start Atom, open the Settings view, and click Packages.
- Choose atom-beautify, and deselect Beautify on Save for these three languages: HTML, JavaScript, and JSX.
- Choose prettier-atom, and deselect Format Files on Save.
How to Format React JSX Code
There are two ways two automatically format JSX code in Atom:
- Use the Packages Menu:
Select the JSX code in Atom, and then choose Packages > Prettier > Format.
- Use a Keyboard Command:
Windows: Select the JSX code, and then press
cntrl + alt + f
MacOS: Select the JSX code, and then press
control + option + f