Search code examples
ngrxngrx-storengrx-effectsngrx-entity

A action is seemingly overwriting another unrelated slice


I'm not quite sure how to explain this, but here is a picture that could help explain the issue that I seem to be facing.

enter image description here

As you can see, I have a SharedNotificationsModule and a SharedConversationsModule, these are totally separate to one another and each contain their own state files.

I am importing the SharedNotificationsModule into my SharedHeaderModule as this is where the majority of notification related content will be.

However, if I navigate to the ConversationsPage and the LOAD_CONVERSATIONS_SUCCESS is triggered my previous notifications slice is being overwritten.

This isn't only happening on the LOAD_CONVERSATIONS_SUCCESS action, this happens on other pages but some times the action that get's the user or the action that get's a users profile (when navigating to the users profile page).

I'm not sure what/if any code you would like to see, but just let me know what you want.


Solution

  • I finally figured this out now, turns out that I had forgotten to add a default to the switch in my notificationsReducer. The default now just returns the existing state.

    default: 
        return state;