【问题标题】:Is it possible not to use next-redux-wrapper in nextjs for Redux? Is Context+useReducer will be enough for state manager in NextJS apps?是否可以不在 nextjs 中为 Redux 使用 next-redux-wrapper? Context+useReducer 对于 NextJS 应用程序中的状态管理器是否足够?
【发布时间】:2021-08-11 04:15:46
【问题描述】:

我需要在 NextJS 应用程序中使用状态管理器,并且我使用 Redux。但是在使用它的时候,我必须使用一个 next-redux-wrapper 并且一切看起来都非常复杂。有人说 next-redux-wrapper 效果不好,有一些缺陷和问题。而且一般来说,当涉及到 NextJS 时,它并不是真正需要 Redux 并且使用上下文就足够了。但是上下文的重新渲染有其自身的问题。帮助我理解。我完全糊涂了。 NextJS 应用程序的状态管理器实际使用什么?

【问题讨论】:

    标签: reactjs redux next.js


    【解决方案1】:

    您可以在没有 next-redux-wrapper 的情况下在 Next 应用程序中使用 Redux。这是来自 vercel https://github.com/vercel/next.js/tree/canary/examples/with-redux 的示例。

    但是,next-redux-wrapper 让您避免每次在服务器上渲染时都实例化存储和其他方便的功能。

    综上,如果你是使用 Next 做静态应用,简单的 redux-toolkit 配置就足够了,否则考虑使用 next-redux-wrapper。

    【讨论】:

      猜你喜欢
      • 2021-04-28
      • 2022-01-20
      • 2021-07-04
      • 2022-06-15
      • 2021-12-19
      • 2021-11-18
      • 2021-11-18
      • 2015-10-17
      • 2020-05-16
      相关资源
      最近更新 更多