It’s the must frustrating thing! I can finally start doing pretty cool things using JS and React, but I can only do them on websites like FCC, or scrimba. I don’t know if I’m simply importing React incorrectly, or there is a problem with my syntax, but I have never been able to get React to work from VS Code on my computer. I’m not sure the best way to ask for help setting up a local work space, but I desperately need it. Right now all I want to be able to do is have React render ‘hello world’ on a webpage.
Is anyone willing to walk a newbie through?
In my open folder on VS Code I have:
index.html:
<html>
<head>
<link rel='stylesheet' href='style.css'>
</head>
<body>
<div id='root'></div>
<h1>At least this works</h1>
<script src='index.pack.js'></script>
</body>
</html>
index.js
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
ReactDOM.render(<App />, document.getElementById('root'))
App.js
import React from 'react'
class App extends React.Component {
constructor() {
super()
this.state = {
name: 'Alex'
}
}
render() {
return (
<div>
<h1>Hello World</h1>
</div>
)
}
}
export default App
style.css
blank.