Next.js Discord

Discord Forum

useEffect is not working on latest version

Answered
Little fire ant posted this in #help-forum
Open in Discord
Little fire antOP
I have started a fresh new project using npx create-next-app@latest command. Now, I am trying to use useEffect hook on page.tsx but it's not firing.

Here's the code-

"use client";

import Image from "next/image";
import { useEffect } from "react";

export default function Home() {
useEffect(() => {
alert("asd");
console.log("first");
}, []);

return (
// rest of the code
);
}

You can check the repo too- https://github.com/Shofol/nextjs-issue/blob/main/app/page.tsx
Answered by Little fire ant
Got the problem. It was related to Node.js version!
https://github.com/vercel/next.js/discussions/55931
View full answer

8 Replies

Cuvier’s Dwarf Caiman
can you check and include the Ip adress and port and that the dev server is actually running?
Little fire antOP
It's running on my localhost:3001
Cuvier’s Dwarf Caiman
and is your screenshot from the console also from 3001?
3001 is usually the port if 3000 is already taken
could it be that you watch the console of the :3000 instance?
Little fire antOP
No man, it's same. Can you clone the repo and check on your machine?
Little fire antOP
Got the problem. It was related to Node.js version!
https://github.com/vercel/next.js/discussions/55931
Answer