#Failed while importing Header component to layour.js

6 messages · Page 1 of 1 (latest)

onyx marten
#

I'm trying to use the new version of NextJS and I'm importing my Header component inside the new layout.js file but i'm getting an error:

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

I tried adding 'use client' to the header component but it doesn't seem to work

Down below the files if you want to see them

native spruce
onyx marten
#

now i got it on top of Header.js, the layout is rendering but its kinda messed up and i get this error in console

#

nvm, the problem was that the Header was not inside the body