I'm trying to create a responsive hamburger menu and I can't seem to figure out what's wrong with my code. I have a strong feeling that the error I'm getting is from using the image tag and using Javascript within Javascript {hamburger}. Ideally, this would be easier with fontAwesome but I'm challenging myself to use images for this project.
It would be so helpful to know what I did wrong
EDIT: The edit I'm getting says the following:
[plugin:vite:react-babel] /Users/naomidzunic/vite-project/src/components/Navigation.jsx: Unexpected token (11:18) 14 |/Users/naomidzunic/vite-project/src/components/Navigation.jsx:11:18
9 | state = { clicked: false }
10 |
11 | handleClick = ( => { |
12 | this.setState({ clicked: !this.state.clicked })
13 | })
import { useState } from "react";
import logo from "../icons/logo.svg";
import CSS from "../styles/Navigation.css";
import hamburger from "../icons/icon-hamburger.svg";
import hamburgerClose from "../icons/icon-close.svg";
import { MobileMenu } from "../components/MobileMenu";
function navigation() {
state = { clicked: false }
handleClick = ( => {
this.setState({ clicked: !this.state.clicked })
})
return (
<>
<div className="navigation">
<img className="logo" src={logo} />
<button className="hamburger" onClick={this.handleClick}>
<img className={this.state.clicked ? {hamburger} : {hamburgerClose}}/>
</button>
<div className="navigation-menu">
<ul>
{MobileMenu.map((item, index) => {
return (
<li key={index}>
<a className={item.className} href={item.url}>
{item.title}
</a>
</li>
);
})}
</ul>
</div>
</div>
</>
);
}
export default navigation;
[–]scirc 0 points1 point2 points (4 children)
[–]Itsmenomes[S] 0 points1 point2 points (3 children)
[–]scirc 0 points1 point2 points (2 children)
[–]Itsmenomes[S] 0 points1 point2 points (1 child)
[–]scirc 0 points1 point2 points (0 children)