[Bug?]: hydration fails silently without an error
Duplicates
- [x] I have searched the existing issues
Latest version
- [x] I have tested the latest version
Current behavior 😯
no error in console, but hydration fails expectedly
Expected behavior 🤔
TypeError: global is not defined
Steps to reproduce 🕹
console.log(global);
export default function Home() {
return <button onClick={() => console.log("not interactive")}>Click</button>;
}
Context 🔦
No response
Your environment 🌎
I am facing the same problem. for some reason the click event is not working.
so I had imported a server function into my component and when I removed it then click event started working. basically , I removed the following line: import { getUser } from "~/lib/auth";
but i need to use getUser in my component. there is no problem with the server function itself. I can get User info perfectly.
so I had imported a server function into my component and when I removed it then click event started working. basically , I removed the following line: import { getUser } from "~/lib/auth";
but i need to use getUser in my component. there is no problem with the server function itself. I can get User info perfectly.
make sure lib/auth has "use server" at the top and only exports functions
@huseeiin is this still an issue? Im not sure you have access to global in that context
@huseeiin is this still an issue? Im not sure you have access to global in that context
i know, the point is i expect an error like "global is not defined" in the browser for better dx and debugging
when i put it in the component, it throws an error as expected:
export default function Home() {
console.log(global);
return <button onClick={() => console.log("not interactive")}>Click</button>;
}
Okay to answer this, console.log(global) as a module-level call would cause a global error, which stops JS execution in general, there's no hydration error because that error isn't part of the hydration perse, heck, hydration wouldn't even run because of the error.
Okay to answer this,
console.log(global)as a module-level call would cause a global error, which stops JS execution in general, there's no hydration error because that error isn't part of the hydration perse, heck, hydration wouldn't even run because of the error.
interesting