NgRx Action的type属性覆盖State中对象的type属性问题求助
NgRx Action的type属性覆盖State中对象的type属性问题求助
各位好,我最近在使用NgRx的时候碰到了一个头疼的问题:我想把通知的type属性(一个包含icon和typeId的对象)保留在State的对象数组里,但现在Action自身的type属性(也就是[Notifications] updateNotifications这个字符串)把我State里每个notification对象的type给覆盖了!
我期望的notification对象里的type应该是这样的:
type: { icon: "check_circle", typeId: "info" }
但实际得到的却是Action的类型字符串:"[Notifications] updateNotifications",完全不是我想要的结构。
下面是我的相关代码:
接口与初始State定义
export interface notification { date: string; description: string; time: string; title: string; type: { icon: string; typeId: string; }; } export interface NotificationsState { data : notification[]; } export const initialState: NotificationsState = { data: [], };
Action定义
export const updateNotifications = createAction( '[Notifications] updateNotifications', props<{ notification: notification }>(), );
我是按照上面的方式处理数据,然后把数据作为Action的参数传递的,但结果就出现了这个覆盖的问题,有没有大佬能帮我看看哪里出问题了?
备注:内容来源于stack exchange,提问作者Jmainol
相关产品推荐
相关产品推荐

