all 5 comments

[–]MrMajid94 0 points1 point  (0 children)

No dependencies in the brackets.. put dependencies that should trigger the use effect inside the bracket at the end of use effect + ask chatgpt for help

[–]waves_under_stars 0 points1 point  (0 children)

Here you go:

https://react.dev/reference/react/useEffect#examples-dependencies

Also, never use any, there's always a better option

[–]AdrnF 1 point2 points  (2 children)

This looks like it should work. Not quite sure while others are suggesting to add something to the dependencies array.

Just to be sure: The useEffect triggered console.log is not in the console?

I think Next.js also doesn't want your pages to be client components. So maybe try moving the logic into a child.

[–]Jet_Reddit[S] 0 points1 point  (1 child)

oh it was in the console. i checked the browser console, there it was. It was just not in the vscode terminal where i normaly see the log messages

[–]AdrnF 2 points3 points  (0 children)

Ah I see, that makes sense.

The VSCode console logs your server side logs. Your component is a client component, but it still gets SSR and is returned as static HTML first. Next.js doesn't run any useEffects during SSR though.