简体   繁体   English

由于 SSR,Reactotron 不适用于 NextJS

[英]Reactotron doesn't work with NextJS because of SSR

I'm configuring the redux store for my NextJS application and i usually use the Reactotron library to inspect the store.我正在为我的 NextJS 应用程序配置 redux 存储,我通常使用 Reactotron 库来检查存储。 But, NextJS is server side rendering and if i import the configuration in the app file, it gives an error window is not defined但是,NextJS 是服务器端渲染,如果我在应用程序文件中导入配置,它会给出一个错误window is not defined

That's my config file: https://github.com/LauraBeatris/amazon-next/blob/develop/src/config/ReactotronConfig.js这是我的配置文件: https : //github.com/LauraBeatris/amazon-next/blob/develop/src/config/ReactotronConfig.js

And my app file: https://github.com/LauraBeatris/amazon-next/blob/develop/src/pages/_app.js还有我的应用程序文件: https : //github.com/LauraBeatris/amazon-next/blob/develop/src/pages/_app.js

I want to know if there's a way of using Reactotron with NextJS我想知道是否有一种方法可以将 Reactotron 与 NextJS 一起使用

In NextJS you can dynamically import a module on the client side only.在 NextJS 中,您只能在客户端动态导入模块。 You should import it like this :你应该像这样导入它:

import dynamic from "next/dynamic"

const DynamicComponentWithNoSSR = dynamic(
  () =>  import '~/config/ReactotronConfig',
  { ssr: false }
)

But I'm not sure if Reactotron will work the way you expect, as I don't know the library.但是我不确定 Reactotron 是否会按照您期望的方式工作,因为我不了解该库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM