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.
Source: stackoverflow.com
Related Query
- React import external javascript returning error
- React Native Error - yarn' is not recognized as an internal or external command
- Call external Javascript function from react components
- Import third-party JavaScript library that normally self-executes into React app (using create-react-app)
- How import object from external JS file in React JS using web pack
- Fetch api post call returning 403 forbidden error in React js but the same URL working in postman
- React app returning 500 Internal Server Error
- Next.js: How to dynamically import external client-side only React components into Server-Side-Rendering apps developed?
- Webpack 5 Receiving a Polyfill Error?!?! My JavaScript React project is receiving a polyfill error while trying to compile my webpack.config.js file
- Getting error when try to use React Router v6: Attempted import error: 'Action' is not exported from 'history'
- Import External CDN in React Component
- React component function returning JSX causes error when used in render method of ES6 class React component
- Can you import an external CSS file in a React js file?
- Error no Jest: This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript
- Call external Javascript function from react typescript components
- Call react component's function from external JavaScript function
- Adding external javascript script to React
- How do you embed and call an external javascript function in a react component?
- import ReactCSSTransitionGroup in ES6 React Javascript
- Cannot find file: 'index.js' does not match the corresponding name on disk: '.\node_modules\React\react' error with React import correct
- Error on import JSON with Webpack 4.5 + Babel 6 + React 16
- npm run build on my react app gives error => (Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out out of memory)
- Superagent error handling React Javascript
- React hook error is returning an empty object
- Import error firebase/firestore using react
- Import error while importing bootstrapJS file in react
- Error resolving module specifier: react while doing dynamic import from API
- How will my React.render function access external javascript file containing react code?
- Key error when there is already one on Javascript and REACT AXIOS
- React javascript syntax error on question mark and dot
More Query from same tag
- useEffect constant post request
- Array.includes returning conflicting results on react component load
- Redux state change in componentWillMount is not be recognized in componentDidMount?
- Error: How to serialize data from getStaticProps : Next.js
- Fetch API work on POSTMAN and express server but does not work on React js
- Reading GET in REACT serves NODEJS
- display an image in react based on a response
- getting Not found page on every page at buttom React js
- Slice vs filter in redux delete action
- React useEffect looping many times when fetching data and setState using fetch API
- Passing CSRF token to REACT/FLUX from node
- JSX in fuction donot update state
- Send value to parent function when class renders a child component
- Get All The youtube video from specific channel in reactjs
- Basic problem React with express dynamic table
- How to get all the keys from a specific doc of a collection in firestore?
- Using the Webpack dev server with a PHP application
- How to Change Value of Provider in React Hooks
- Custom react hook with useeffect, cant use in non-component function
- ReactJS - Lightbox component Issue
- Handler not working as expected in child component in React
- Can't access nested object properties in a single object from JSON call in REACT
- How to add new child key-value to a React State object
- useSelector and UseEffect with dispatch functions create loop due to not updating state
- How to use a custom template in Keystone.js using React?
- TypeError: tasks.map is not a function
- MongoDB / Express / React - How to define the variable name which will be saved in the db
- How to use Link components in Menu.List elements
- value is always empty inside ternary operator statement
- How do I check if a React component is expecting a prop?