Search code examples
angularreduxngrx

How avoid NgRx action'type property override my state type property


I need to keep the property type into my array of object which make up the 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: [],
};

I process the data this way and send it as the argument of my action this way:

enter image description here

The issue is the action type is overriding the type property of my state:

enter image description here

I would like to have this value type:

type: {
  icon: "check_circle",
  typeId: "info"
 }

but I got this: "[Notifications] updateNotifications"

Which is the type of my action:

export const updateNotifications = createAction(
  '[Notifications] updateNotifications',
  props<{ notification: notification }>(),
);

Solution

  • I believe NgRx uses under the hood the keyword type for handling actions. Look at the docs

    Try changing your property name for Notification from type to something else, like notificationType