Next.js Discord

Discord Forum

next.js useState problem.

Unanswered
Asian swamp eel posted this in #help-forum
Open in Discord
Asian swamp eelOP
Not able to use useState in next.js

Hey everyone I am kind of beginner to next.js.
My concern is I was watching a tutorial and they were using useState and their code was working properly I copied the code but mine is not working.

I even found this question on Google but I didn't get the answer.

Code of page.js

||||||||||
"use client"

import React, { useState } from 'react'

const Page = () => {

const [marks, setMarks] = useState(80)

return (
#Unknown Channel
<h1>My marks were {marks}</h1> <button onClick={() =>{setMarks(33)}}>Update</button>
</>
}

export default Page

||||||||||||||

When I click on to update button nothing changes.
Please guide me.

1 Reply