Can someone please help me with the following code issue? I am encountering an error related to the script tag when running it in ReactJS, although it works fine in a simple HTML file.
Upon starting npm, an error is displayed pointing to line number which prevents the code from running.
./src/topbar/Navbar.js Syntax error: C:/Users/root/mft/src/topbar/Navbar.js: Unexpected token, expected } (34:62) 32 | 33 | function openNav() { > 34 | document.getElementById("mySidenav").style.width = "250px"; | ^ 35 | document.getElementById("box1").style.width = "100%"; 36 | } 37 |
import React from 'react';
import './Navbar.css';
class Navbar extends React.Component {
render(){
return(
<div id = "navbar">
<div class ="box">
<div class="side" onclick={openNav()}>
<div class="line-separator"></div>
<div class="line-separator"></div>
<div class="line-separator"></div>
</div>
<h1 class="right">A1MAN </h1>
<div class="text">
<h1>A1MAN </h1>
</div>
</div>
<div id="box1" class="back">
<div href class="closebtn" onclick={closeNav()}></div>
</div>
<div id="mySidenav" class="sidenav">
<a href="">About</a>
<a href="">Services</a>
<a href="">Clients</a>
<a href="">Contact</a>
</div>
<img alt="flower" src="http://www.byui.edu/images/agriculture-life-sciences/flower.jpg"/>
<script>
</script>
</div>
);
function openNav() {
document.getElementById("mySidenav").style.width="250px";
document.getElementById("box1").style.width = "100%";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
document.getElementById("box1").style.width = "0";
}
}
}
export default Navbar;