score:1

Accepted answer

add the payload to the front of the notifications and then slice off the rest (this way you also have latest notifications upfront.

    case "add_notification":
        return [{...action.payload}, ...(state.slice(0,2))];
    }

Related Query

More Query from same tag