react scripts 很久没有更新了,react 新文档也推荐使用 nextjs ,准备从 cra 迁移到 nextjs ,大家有使用 next export 的吗,有没有什么坑
|
heishuMay 4, 2023
1
也许有吧,比如 cra 肯定是 client 端渲染,但是 next 还有服务端渲染,有些三方库在 next 就会报错 window 为空,就需要 next 只在 client 端执行代码
|
|
2
@heishu 最近把一个 cra 项目迁移到了 nextjs 的 export 模式,好处暂时还没感受到,坑着实遇到了几个。
window 为空的问题需要把组件用 dynamic 包起来,ace quill jsoneditor 都有这个问题,还有一些 hydrate render 等等问题待慢慢解决 总结就是跟着潮流走,折腾一下 |
|
3
不使用 nextjs 的 ssr 着实没有使用 nextjs 的必要,然后控件库的引入对 ssr 支持也十分差劲,最终换为 vite
|