It's a simple use-case. Trying to send a list of id's from that client mapping (a client managing system) to all server components. How is this done in nextjs?
import ClientComponent from './client-component'
import ServerComponent from './server-component'
export default function Page() {
return (
<ClientComponent>
<ServerComponent />
</ClientComponent>
)
}
but the client component manages the server components, as you can see below
export default function ClientComponent({ children }: ChatClientProps) {
const [chats, setChats] = useState<string[]>(['cuT9MKk', 'EufJ5I8'])
const addChat = (id: string) => {
setChats([...chats, id])
}
const removeChat = (id: string) => {
setChats(chats.filter(chatId => chatId !== id))
}
return (
<div className="group flex w-full">
{chats.map((id, index) => (
{children id={id}}
))}
</div>
)
}