Igor Sushko
Igor Sushko

Reputation: 1

VS Code how to combine HTML into .JS file?

I try to create a React project in VS Code. When I try to save index.js with the HTML tags as below, VS Code breaks my tags and pushes spaces between words and brackets. Can’t find how I can fix it…

// this is before I safe the project
ReactDOM.render( <div> Hello World! </div>, document.getElementById('root'))

// this is after I safe the project
ReactDOM.render( < div > Hello World! < /div>, document.getElementById('root'))

Upvotes: 0

Views: 727

Answers (1)

cezn
cezn

Reputation: 3035

Either:

  1. Change all .js file extensions to .jsx.
  2. Add file association in user/workspace settings:
"files.associations": {
    "*.js": "javascriptreact"
  }

Upvotes: 1

Related Questions