/
githubmirror
/
next.js
Обзор
Документация
Войти
/
githubmirror
/
next.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
canary
errors/react-client-hook-in-server-component.mdx
43 строки
798 B
Delba de Oliveira
Docs IA 2.0: Server and Client Components (#79143)
15 май 2025, 16:26
Не верифицирован
15 май 2025, 16:26
9c757f6
Код
Авторство
О чём код?
--- title: React client hook in Server Component --- ## Why This Error Occurred You are using a React client hook in a Server Component. ## Possible Ways to Fix It Mark the component using the hook as a Client Component by adding `'use client'` at the top of the file. ### Before ```jsx filename="app/example.js" import { useEffect } from 'react' export default function Example() { useEffect(() => { console.log('in useEffect') }) return <p>Hello world</p> } ``` ### After ```jsx filename="app/example.js" 'use client' import { useEffect } from 'react' export default function Example() { useEffect(() => { console.log('in useEffect') }) return <p>Hello world</p> } ``` ## Useful Links - [Server Components](/docs/app/getting-started/server-and-client-components)