LoginSignup
4
2

More than 3 years have passed since last update.

VSCodeでReact-JSXを保存するとき勝手に改行されちゃう問題

Posted at

問題

VSCodeで下記のようなDOMを書いて

ReactDOM.render(
  <React.StrictMode >
   <App />
  </React.StrictMode>,
  document.getElementById('root')
);

保存(⌘+S)しようとすると、勝手に改行されてしまう問題。
もちろんエラーになります。

ReactDOM.render(
  <
React.StrictMode >
  <
  App / >
  <
  /React.StrictMode>,
  document.getElementById('root')
);

解決策

VSCodeの設定を変更します。
Settings.jsonファイルを開き、下記を追加します。

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

以上です。

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2