Issue: Despite restarting server many times with npm start, same old error is showing up.
./src/components/slider.js
Line 9:25: Parsing error: Unexpected token
--------------------------------------------------------------------(The Actual code edited is below)...............................
import React,{Component} from 'react';
class Monty extends React.Component {
render(){
return(
Automatic
<script>
var myIndex = 0;
carousel();
kk
function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
myIndex++;
if (myIndex > x.length) {myIndex = 1}
x[myIndex-1].style.display = "block";
setTimeout(carousel, 2000); // Change image every 2 seconds
}
}
}
);
export default Monty;
What is troubling me is despite closing the server and refreshing it , same error is showing up.
Already tried following Solutions:
1- Adding REACT_EDITOR=atom ( including .env file )
2- Closing the server and restarting it,
3- Deleting all history from Browser chrome .
I am new to React, so not sure why this error is happening and how i can rectify the same.
Addtional Information: App.js
import React from 'react';
import MyForm from './components/form';
import Imagine from './components/test';
import {Button, Badge} from 'react-bootstrap';
import 'bootstrap/dist/css/bootstrap.min.css';
import Monty from './components/slider';
Do you want to fetch and execute the script, again and again, every time this component is rendered, or just once when this component is mounted into the DOM
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.
Issue: Despite restarting server many times with npm start, same old error is showing up. ./src/components/slider.js Line 9:25: Parsing error: Unexpected token
7 | 8 |
--------------------------------------------------------------------(The Actual code edited is below)............................... import React,{Component} from 'react';
class Monty extends React.Component { render(){ return(
Automatic
var myIndex = 0; carousel(); kk function carousel() { var i; var x = document.getElementsByClassName("mySlides"); for (i = 0; i < x.length; i++) { x[i].style.display = "none";
} myIndex++; if (myIndex > x.length) {myIndex = 1}
x[myIndex-1].style.display = "block";
setTimeout(carousel, 2000); // Change image every 2 seconds }
Already tried following Solutions: 1- Adding REACT_EDITOR=atom ( including .env file ) 2- Closing the server and restarting it, 3- Deleting all history from Browser chrome .
I am new to React, so not sure why this error is happening and how i can rectify the same.
Addtional Information: App.js import React from 'react'; import MyForm from './components/form'; import Imagine from './components/test'; import {Button, Badge} from 'react-bootstrap'; import 'bootstrap/dist/css/bootstrap.min.css'; import Monty from './components/slider';
function App() {
return (
F L I R T
Best Offersexport default App;
Wrap your code in Github in triple tildes ``` to create code blocks.
Why are you returning scripts in the JSX? Its not working probably because there are errors parsing it
Do you want to fetch and execute the script, again and again, every time this component is rendered, or just once when this component is mounted into the DOM
Use template literals inside styles
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.