Next.js Discord

Discord Forum

Mui Joy Button doesn't work

Answered
French Lop posted this in #help-forum
Open in Discord
French LopOP
const handleClick = () => {
console.log("clicked")
}

return (
#Unknown Channel
<Button onClick={handleClick}>Register</Button>
</>
)

when i click the button nothing happens idk why
Answered by riský
tbh you should update as 18 is LTS now or 20 for latest
View full answer

28 Replies

where is Button defined
French LopOP
import { Button, Typography } from '@mui/joy'
and do normal onclicks for buttons work?
as if so, you should bring this up with mui as nextjs can't control it as far as i know
@riský and do normal onclicks for buttons work?
French LopOP
what do you mean with a normal onClick?
like create a button (just plain and basic one)
and put the same onClick event on it
French LopOP
nah its not working
i am on a client component
but you say that you just did a <button onClick={handleClick}>Register</button> not imported anywhere
French LopOP
<button onClick={handleClick}>CLICK IT</button>

yes the basic html button also didnt work
firstly, can you try clearing .next folder
secondly, check that js isn't disabled in your browser (and tab)
thirdly, make sure button isn't imported/defined anywhere else
French LopOP
nothing helps
and can you try a fresh project (next build && next start) with just that code
French LopOP
maybe theres a problem because i am using src folder
it shouldn't do anything negatively
and you are using nextjs v13.5.2? (latest)
French LopOP
yes its the latest next version
v16.10.0 for node
French LopOP
i will try a new project maybe just a weird bug
@French Lop v16.10.0 for node
tbh you should update as 18 is LTS now or 20 for latest
Answer
French LopOP
lamo using v20 now
its working
my bad i thought v16.10 works but next requires 16.14
well thats a different bug, but yay its fixed!
French LopOP
thanks a lot 😄