谁能告诉我为什么我的状态总是未定义。我是NgRx新手
reducers.ts
import * as actions from "./actions"
import * as _ from "lodash"
export interface State {
cards: any[]
}
export const initialState: State = {
cards : []
}
export function reducer(state = initialState, action: actions.Actions): State {
s
我正在尝试使用NGRX状态管理库来实现一个应用程序,我能够创建动作和还原器来将数据推送到延迟加载状态。但我很难实现选择器来获取组件的数据。这就是我迄今为止所做的
reducer/job-file.reducer.ts这里我使用的是ngrx实体插件
import {Action, createReducer, on} from '@ngrx/store';
import * as JobFileActions from '../actions';
import {JobFile} from '../../models/job-file.model'
我正在尝试将ngrx引入一个大型遗留的角应用程序(升级到角11)。该应用程序有一个巨大的模型,可以保存几乎所有的数据,不能调整,因为它在公司广泛使用。
其想法是将模型的一个实例放入ngrx存储中,并在"immer“和”ngrx“的帮助下更新相关部件。
我的问题是,更新其中的部分会导致以下错误
// in the reducer
dashboard.widgets.push(action.widget)
ERROR TypeError: Cannot add property 1, object is not extensible
at Array.push (<
我在我的Angular 12项目中使用了ngrx,并希望实现ngrx-store-logger来记录我的操作和存储。这是我的app.module.ts的一部分 import { storeLogger } from 'ngrx-store-logger';
import { environment } from 'src/environments/environment';
export function logger(reducer: ActionReducer<AppState>): any {
// default, no option
在安装ngrx store和ngrx effect并编写我的action、reducer和effect.I之后,我的控制台出现了30个错误,尝试删除了node_modules,重新安装了我的所有软件包,以及来自的一些建议。
这是控制台中的错误
ERROR in node_modules/@ngrx/store/src/feature_creator_models.d.ts:3:23 - error TS1005: ']' expected.
3 [K in FeatureName as `select${Capitalize<K>}State`]: Mem
我已经将我的应用程序更新到了角4,据我所知,它不应该导致很多的破坏变化,除了动画。
但是,我以前工作的应用程序失败了,例外情况是:
Uncaught TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at combineReducers (vendor.bundle.js:68589)
at Object._initialReducerFactory [as a] (vendor.bundle.js:68531)
它似乎是由ng-rx存储引
声明一个ActionReducerMap中所有的reducers都可以反应的"INIT_ACTION“的正确方法是什么? 这是我的代码的一个例子,我需要所有3个reducers (图像,标签,addedTags)来对一个动作做出反应: import { ActionReducerMap, createFeatureSelector } from '@ngrx/store';
import * as fromRoot from '../../../store';
import * as fromImages from './image.red
错误的意思是,它在action参数之后在.map中使用逗号。
在DataActions.AddDataAction上盘旋时也有一个错误,上面写着Tuple type '[Action, AppStore]' with length '2' cannot be assigned to tuple with length '5'
@Effect() addData$ = this.actions$
.ofType(DataActions.ADD_DATA)
.withLatestFrom(this.store$)
.map((