My Django project has the following structure:
I am displaying questions.html
in the browser:
<html>
<head>
</head>
<body>
Questions:
<div id="questionSpace"></div>
<script src="../js/frontEnd/src/App.js"/>
</body>
</html>
questions.html
is referencing the code from App.js
which is:
import {React, Component} from 'react';
import logo from './logo.svg';
import ReactDOM from 'react-dom';
import './App.css';
class App extends Component {
componentWillMount() {
fetch(`http://localhost:8000/api/questions`)
.then(result => {
this.setState({questions: result.json()})
})
}
render() {
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Welcome to React</h2>
</div>
<ul>
{this.state.questions.map(question => <li>question.content</li>)}
</ul>
</div>
);
}
}
ReactDOM.render(<App />, document.getElementById("questionSpace"));
For some reason, the javascript code is not included in the html page.
Any idea what could cause this?