onClick not firing #15226
-
|
I have a standard page with a link that I want to use to toggle the showing of another component: import React from 'react'
export default class Page extends React.Component {
render(props) {
<a onClick={() => console.log("wow")}>Click here</a>
}
}When clicking the link nothing happens in the console. I've tried various ways of doing this. I tried doing it in a page directly, in a subcomponent, etc but it doesn't work at all. If I What do I have to do to be able to make proper client side rendered React things in Next? |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 16 replies
-
|
That worked for me, although you have a syntax error with your render method: import React from 'react'
export default class Page extends React.Component {
render() {
return <a onClick={() => console.log("wow")}>Click here</a>
}
}Do you have any other code you could share? |
Beta Was this translation helpful? Give feedback.
-
|
Honestly don't know what was wrong. Taking your code directly did not work. |
Beta Was this translation helpful? Give feedback.
-
|
I'm having same issue as well |
Beta Was this translation helpful? Give feedback.
-
|
In my case, I had to rename the file name of the component in lowercase. After that, all click listeners worked. Ex: Footer.js (old file name) -> footer.js |
Beta Was this translation helpful? Give feedback.
-
|
i'm having same issue in the component, when i try in the |
Beta Was this translation helpful? Give feedback.
-
|
I was having the same issue, finally found that I was mistakenly loading the server side env variable from client side with |
Beta Was this translation helpful? Give feedback.
-
|
Was having the same issue, found that it was because I was doing it in
|
Beta Was this translation helpful? Give feedback.
-
It`s 2023 and problem is alive. Any chance to get solved closely ? UPDATE: |
Beta Was this translation helpful? Give feedback.
-
|
I forgot to add |
Beta Was this translation helpful? Give feedback.
-
|
any hydration problem also can make entire(in anywhere) onclick doesn't work I used 4 hours :( |
Beta Was this translation helpful? Give feedback.


That worked for me, although you have a syntax error with your render method:
Do you have any other code you could share?