score:2

Accepted answer

if you are using static files, you should add them into the public folder in your react project, for example:

your_project_folder
|_public
  |_index.html
  |_static
    |_scripts-init
      |_demo.js

and then just refer to it with relative path, like:

<script src="/static/scripts-init/demo.js"></script>

this is because the code gets transpiled by webpack (or the default transpiler) and generates a dev build where the 'src' folder does not exist.


Related Query

More Query from same tag