In my project, I am trying to tie together Django and React.
import React from "react"; import ReactDOM from "react-dom"; import "./index.css"; import App from "./App"; import reportWebVitals from "./reportWebVitals"; import "./styleguide.css"; import "./globals.css"; ReactDOM.render( < React.StrictMode > < App / > < /React.StrictMode>, document.getElementById("root") ); reportWebVitals();
I have looked at this post, and confirmed that this solution is not applicable for me.
The primary issue, I think, is that Django is serving the html, but not running the .js, so I’m unsure of where to go with this.
I have also confirmed that the image linking is working as well, so I’m not getting 404 errors or anything like that.
Secondary, semi-related question: Should I be linking the favicons like this? I get the feeling I shouldn’t be serving the html statically, but I was unable to find how exactly to serve the project, other than serving the html statically.
(edit) I have added in the script as in comments, but now I get an error where Django seems to reject the React tags.
Your HTML file has no
<script> tag for your
index.js (although, interestingly, it does have a
You need to tell your page about every JS file you want to run, which you do by using
See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script for more info.