javascript 我可以在Next.js 13.1中使用哪个React组件库?[副本]

xam8gpfp  于 2023-05-21  发布在  Java
关注(0)|答案(1)|浏览(255)

此问题已在此处有答案

You're importing a component that needs useState. It only works in a Client Component, but none of its parents are marked with "use client"(1个答案)
昨天关门了。
我是Next.js的新手。尝试13.1版本和新的app目录。
有可能这样做吗?而不失去服务器控件的新好处?
我看到以下错误:

You're importing a component that needs useState. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.
huwehgph

huwehgph1#

  • useState* 钩子只在客户端运行。如果您的组件使用它,请考虑在组件文件的顶部添加 “use client” 指令。这将在服务器上预呈现您的标记,并在重新水合后运行“useState”钩子。

相关问题