Server component state management?

Would there be a way to get the benefits of the server components while using a state management library?
4 Replies
Neto
Neto2y ago
with server components you don't manage the state on client if you try something like useState on a server component you will receive an error
Informa
InformaOP2y ago
Indeed but still I don't want to send a request to the server every time a click affects the entire page
Neto
Neto2y ago
then create a client component
'use client';
import { useClient } from 'react';

export const SomeComponent = () => {
const [some, setSome] = useState('')

return null
}

// somewhere/not/in/pages/dir/elem.tsx
'use client';
import { useClient } from 'react';

export const SomeComponent = () => {
const [some, setSome] = useState('')

return null
}

// somewhere/not/in/pages/dir/elem.tsx
Informa
InformaOP2y ago
Oh yeah I can do that I'll try tomorrow and update you!
Want results from more Discord servers?
Add your server