Why do onClick listeners not work with Static Site Generation? #16890
-
Hi! Take this code snippet for example:
When I run the project in dev mode, this works as expected, on each click the value is incremented. Essentially, I noticed this when porting a regular React project into a Next project, and the Dark Mode toggle button stopped working, along with the nav menu expand/collapse. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Unable to replicate. My guess is that your production server isn't serving JS assets. Working (local staging) example: https://github.com/mattcarlotta/with-static-counter If you're still running into issues, please provide a working, minimal, and reproducible example of the problem. |
Beta Was this translation helpful? Give feedback.
-
@mattcarlotta I also have this problem. it works fine when in development, but once I export it, the onClick event does not trigger, and also the |
Beta Was this translation helpful? Give feedback.
Unable to replicate. My guess is that your production server isn't serving JS assets.
Working (local staging) example: https://github.com/mattcarlotta/with-static-counter
If you're still running into issues, please provide a working, minimal, and reproducible example of the problem.