【问题标题】:Angular app with NgRx not working properly without redux devtools extension如果没有 redux devtools 扩展,带有 NgRx 的 Angular 应用程序无法正常工作
【发布时间】:2020-12-30 15:42:52
【问题描述】:

如果我禁用了 redux devtools,则应用页面无法正确呈现,直到我单击页面内的任意位置。它不会在我的控制台上显示任何错误。

我的商店模块是

imports: [
    StoreModule.forRoot(reducers, { metaReducers }),
    EffectsModule.forRoot(effects),
    StoreDevtoolsModule.instrument({ maxAge: 25 }),
    // !environment.production && remote flag (dev) & authenticated ? StoreDevtoolsModule.instrument({ maxAge: 25 }) : [],
    StoreRouterConnectingModule.forRoot({
      serializer: CustomSerializer,
    }),
  ]

【问题讨论】:

  • 您收到什么错误?
  • 它不会在我的控制台上显示任何错误

标签: angular ngrx redux-devtools redux-devtools-extension


【解决方案1】:

将选项 strictActionWithinNgZone 设置为 true(默认为 false)。并检查您是否会在商店更新期间收到错误。 看起来您将操作发送到区域之外。

strictActionWithinNgZone
The strictActionWithinNgZone check verifies that Actions are dispatched by asynchronous tasks running within NgZone. Actions dispatched by tasks, running outside of NgZone, will not trigger ChangeDetection upon completion and may result in a stale view.

在这里查看https://ngrx.io/guide/store/configuration/runtime-checks

【讨论】:

  • 我确认通过启用该标志,会出现有助于理解问题的错误。在我的情况下,在使用 _zoneManager.runOutsideAngular 创建的范围内有一个商店调度,只有在没有 Redux 扩展的情况下才会出错
猜你喜欢
  • 2019-01-27
  • 1970-01-01
  • 2014-01-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-05-02
  • 1970-01-01
相关资源
最近更新 更多