Why code in `use client` component still execute in server
Answered
Entlebucher Mountain Dog posted this in #help-forum
Entlebucher Mountain DogOP
I have a ClientComponent with
so why it happens
use client, use sessionStorage inside it, but when run it throw error in server sessionStorage is not defined but the code still works wellso why it happens
Answered by Ray
because client component will be rendered on server and sessionStorage is not avaliable on server
6 Replies
@Entlebucher Mountain Dog I have a ClientComponent with `use client`, use sessionStorage inside it, but when run it throw error in server `sessionStorage is not defined` but the code still works well
so why it happens
because client component will be rendered on server and sessionStorage is not avaliable on server
Answer
@Ray because client component will be rendered on server and sessionStorage is not avaliable on server
Entlebucher Mountain DogOP
thanks for the response, so how can I prevent this?
using dynamic import?
using dynamic import?
@Entlebucher Mountain Dog thanks for the response, so how can I prevent this?
using dynamic import?
how do you use the sessionStorage?
Entlebucher Mountain DogOP
I use sessionStorage (ss) to keep some information to keep some information that I use it on a form in difference screen later
Entlebucher Mountain DogOP
oh, I didn't put this in useEffect
forgot about this, thanks
forgot about this, thanks