Functions cannot be passed directly to client components (FIXED)

preview_player
Показать описание
Hi, I'm Wesley. I'm a brand ambassador for Kinde (paid sponsorship).

👉 Discord: all my courses have a private Discord where I actively participate

⏱️ Timestamps:
0:00 Solution

#webdevelopment #coding #programming
Рекомендации по теме
Комментарии
Автор

Good video, but you gave a solution and then said "this isn't a very good solution." What is a good solution?

dallindavis
Автор

i want to do something like this . anything inside this tag should be rendered on client, but it still renders on server here is my implementation
```
'use client';
import React, { PropsWithChildren, useEffect } from 'react';

function ClientOnly({ children }: PropsWithChildren) {
useEffect(() => {
console.log('CLIENT');
}, []);

return children;
}

export default ClientOnly;

```

haseebiqbal
Автор

Hi, nice video! I have a question. What happens when a page that is strictly for the server attempts to import a client component? Then, the page (server component) passes the function to the client. 🤔

dickimaulanayusuf