I want to use the react component UseState and I want to use the OnClick function, and as I read the docs I've added the "use client" line to the top of the file I'm continuously getting this error SyntaxError: Unexpected token u in JSON at position 0 at JSON.parse (<anonymous>)
Here is a snippet of my code (navbar.js) that is located in the components folder
'use client'
import { useState, useEffect } from "react"
import { navLinks } from "../constants"
import { close, logo, menu } from '../../public'
import Image from "next/image"
import { Poppins } from 'next/font/google'
const poppins = Poppins({
weight: ['400', '700'],
subsets: ['devanagari', 'latin'],
variable: '--font-poppins'
})
export default function Navbar() {
const [toggle, setToggle] = useState(false)
return (
some code here
<div className="sm:hidden flex flex-1 justify-end items-center">
<Image
src={toggle ? close : menu}
alt='menu' className='w-[28px] h-[28px] object-contain'
width={25}
height={25}
onClick={() => setToggle((prev) => !prev)}
/>
</div>
</nav>
)
}
Here is my file structure if it would help:
I import the navbar into the page.js file
Is this a next js bug or am I doing something wrong, any help will be appreciated!