簡體   English   中英

NGRX state 突變

[英]NGRX state mutation

I am developing an enterprise Angular project using Angular CLI and NGRX version 10. Inside a component, I receive a state property via selector and then I change that object. 我沒有收到任何錯誤,這讓我感到困惑,因為 state 是不可變的,但它被靜音而沒有任何錯誤。

默認情況下,ngrx 不會檢測此類錯誤以提高性能。

如果您願意,可以在本地開發期間啟用它們:

@NgModule({
  imports: [
    StoreModule.forRoot(reducers, {
      runtimeChecks: {
        strictStateImmutability: true, // <- what you need
        strictActionImmutability: true, // <- what you need
        strictStateSerializability: true,
        strictActionSerializability: true,
        strictActionWithinNgZone: true,
        strictActionTypeUniqueness: true,
      },
    }),
  ],
})
export class AppModule {}

更多信息在這里: https://ngrx.io/guide/store/configuration/runtime-checks

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM