score:0
i thought you could be using a html file without a server, so in that case when you try to import the file main.js you get an error, you could see an example working here: https://plnkr.co/edit/rlo7u99uvuf5hmzahhe4?p=preview
<!doctype html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.6/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.6/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="example"></div>
<script src="script.js" type="text/babel"></script>
</body>
</html>
try to use a server to render your html file and should work.
score:1
if you are using chromium based web browser, it will happen. you can try mozilla firefox or other mozilla based web browser. chrome will not allow react in this way. moreover, 'type' (text/babel) attribute for script
tag is deprecated. so, it is highly recommended to use react server or other server that support react.
Source: stackoverflow.com
Related Query
- React - Cannot load code from an external file
- How import object from external JS file in React JS using web pack
- React & Jest: Cannot find module from test file
- Dynamically load a React component/bundle from external source
- Load React JS component from external script in "run time"
- How to load a react component written in JSX code from my Javascript code
- React JS - Reading environment configurations from external property file
- Cannot import React JSX from separate file while using Typescript
- How to call a function in react js from an external JS File
- React dotenv cannot load .env file
- Getting API URL from the External File which is not a part of the React app
- Create react app with i18next - load translations from json file
- How to load react component from an external service inside a React app via AJAX
- React js function calling from external file
- Load any kind of data from a local file in a React app
- I am using useReducer hook to for making the custom react hook but below in my code i cannot update state which im receiving from the dispatcher funnc
- How can I load the array images from JSON file in react gatsby?
- Optimise react code to load data from multiple sources simultaneously rather than sequentially
- I have been trying to use Fetch to get data from an external json file with react but kept getting errors
- Cannot get attribute size from File object in React
- Cannot read property formatMessage of undefined error message from react code
- Load JSON file from S3 bucket to React component
- Dynamically Load Project Data from JSON file into React
- React Route Splitting Code cannot load chunk
- Define useSelector type from external file React Typescript
- React - Cannot load image from a list
- React - Passing data from external API to CSV file
- How to fetch data from external json file in React
- How to parse a JSON object from an external file in React using .map() in ES6 and a loop?
- Load function from external script using @loadable/component in React
More Query from same tag
- Prevent refresh while using useNavigate from react-router-dom
- How to add validation in a login page in reactjs
- How to apply active menu in Link in react?
- Access rootState within async effect without specifying payload first
- React render link containing a variable
- How to click an element and move it to another element
- Submit multiple forms with fetch
- How can I check condition in reactjsx?
- BootStrap col-md-4 aligning at right side for 4th object inside map function react
- TypeScript types for passing a React component to React.cloneElement
- How to parse state from one component to another in my example?
- React.js fire event on navigate away from page or page refresh
- Not able to get data from AXIOS inside useEffect()
- React material-ui MenuItem containerElement not working
- Advantages of using immutable.js over Object.assign or spread operators
- PreventDefault in link in React Router not working
- React useReducer not showing value from array.reduce
- How to get material ui pickers value in component?
- How to track changes of a referenced element with React?
- Passing data to react-vega
- React ES6, How to keep decorators in separate files
- React + Formik + Papaparse: cannot access updated state value and instead get undefined
- using button to increment divs in react
- ReactJS Add same function to all children
- Pass state as arguments to switch
- Routing. How do you transfer properties?
- xAxis hides after resize in react rechart
- How to access data within an array of objects sent from client side?
- How can i render a pdf, doc or docx file in reactjs web app
- Overriding add row function in material table