NextJS13 | Handling useState.
Answered
Bald Eagle posted this in #help-forum
Bald EagleOP
Previously when using NextJs 12, I use useState to check wether screen size is small/medium/large
With the current ''use client" does that mean my whole site needs to download everything client side?
That beats the purpose of it no?
With the current ''use client" does that mean my whole site needs to download everything client side?
That beats the purpose of it no?
Answered by riský
yeah
hidden sm:block for hidden on <sm screen (or whatever you are doing)23 Replies
can i ask why you need to know the screen size (and can't use css)
also, you can create client components (so not everything is client)
Bald EagleOP
for the responsiveness
I'll show you sample
From image 1 to image 2
From image 1 to image 2
in that case, can you not use css breakpoints to change hidden?
Bald EagleOP
With breakpoints, I don' think i can add the + sign.
As it can be done using useState no?
As it can be done using useState no?
you can use CSS breakpoints to change a classes visibility
American black bear
Tailwind FTW
Bald EagleOP
You are absolutely right.
Also, with client components
Do i just put the new components there?
Also, with client components
Do i just put the new components there?
you can put them anywhere
@American black bear Tailwind FTW
Bald EagleOP
And yeah i'm using tailwin
i personally postfix it with
client.tsx to make it clear@Bald Eagle And yeah i'm using tailwin
American black bear
then it's way easy
yeah
hidden sm:block for hidden on <sm screen (or whatever you are doing)Answer
American black bear
yeah
Bald EagleOP
Got it!
Thanks for this!
Thanks for this!
@riský i personally postfix it with `client.tsx` to make it clear
Bald EagleOP
Can you explain a little bit more what this means?
@Bald Eagle Can you explain a little bit more what this means?
American black bear
he means, he likes to add client.tsx at the end
like if i make a button that is client component, i could name it
button.client.tsxBald EagleOP
Oh
Okay so you know it's client side
Perfect
Okay so you know it's client side
Perfect
Thanks @riský @American black bear
American black bear
@Bald Eagle Oh
Okay so you know it's client side
Perfect
nice, now you know to simplify and just use css 🙂