【问题标题】:Is it normal, that redux creates so many storage?正常吗,redux 创建这么多存储?
【发布时间】:2021-12-26 15:13:14
【问题描述】:

在终端看到很多行,真的需要创建这么多存储吗?

4. WrappedApp created new store with withRedux(MyApp) { initialState: undefined, initialStateFromGSPorGSSR: undefined }
14:47:39.619    4. WrappedApp created new store with withRedux(MyApp) { initialState: undefined, initialStateFromGSPorGSSR: undefined }
14:47:39.667    4. WrappedApp created new store with withRedux(MyApp) { initialState: undefined, initialStateFromGSPorGSSR: undefined }
14:47:39.673    4. WrappedApp created new store with withRedux(MyApp) { initialState: undefined, initialStateFromGSPorGSSR: undefined }
14:47:39.780    4. WrappedApp created new store with withRedux(MyApp) { initialState: undefined, initialStateFromGSPorGSSR: undefined }
14:47:40.044    4. WrappedApp created new store with withRedux(MyApp) { initialState: undefined, initialStateFromGSPorGSSR: undefined }
14:47:40.061    4. WrappedApp created new store with withRedux(MyApp) { initialState: undefined, initialStateFromGSPorGSSR: undefined }
14:47:40.145    4. WrappedApp created new store with withRedux(MyApp) { initialState: undefined, initialStateFromGSPorGSSR: undefined }
14:47:40.329    4. WrappedApp created new store with withRedux(MyApp) { initialState: undefined, initialStateFromGSPorGSSR: undefined }

这样的线还有几百条。

【问题讨论】:

  • 很难说没有看到任何会导致这种情况的代码。
  • 不,这很不寻常。您可能错误地使用了 Next.js 包装器,但是如果没有代码,就很难判断错误在哪里。
  • 如果您使用getServerSideProps,客户端会在每次路由更改时向服务器请求页面道具,这样会增加日志显示的次数。

标签: javascript reactjs redux next.js


【解决方案1】:

如果你在做 SSR 或 SSG,是的。

您的服务器端存储无法访问您的客户端数据 - 它必须为所有客户端保持数据分离。所以它必须为每个请求创建一个新的商店。

【讨论】:

    猜你喜欢
    • 2021-08-15
    • 1970-01-01
    • 2017-02-16
    • 2022-12-04
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多