skip to Main Content

I wish to render a splash screen in nextjs and after 2secs I wish to navigate to certain screen but I was unable to capitalize on useEffect inside the page.tsx file in nextjs , while importing it is thowing an issue

You're importing a component that needs useEffect. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.

How can I approach and overcome this issue.Thanks in advance for your help.This is my code image

2

Answers


  1. add "use client" on the top of the file

    Login or Signup to reply.
  2. The answer lies on your error in your console, add "use client" on top of the page as instructed

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search