我正在为我的NextJS应用程序配置redux存储,并且我通常使用Reactotron库来检查存储。但是,NextJS是服务器端渲染,如果我在应用程序文件中导入配置,它会给出一个错误window is not defined
这是我的配置文件:https://github.com/LauraBeatris/amazon-next/blob/develop/src/config/ReactotronConfig.js
我的应用程序文件:https://github.com/LauraBeatris/amazon-next/blob/develop/src/pages/_app.js
我想知道是否有办法将Reactotron与NextJS结合使用
发布于 2020-02-13 17:44:43
在NextJS中,您只能在客户端动态导入模块。您应该像导入this一样导入它
import dynamic from "next/dynamic"
const DynamicComponentWithNoSSR = dynamic(
() => import '~/config/ReactotronConfig',
{ ssr: false }
)但我不确定Reactotron是否会像你期望的那样工作,因为我不知道这个库。
https://stackoverflow.com/questions/60197905
复制相似问题