No więc jak w pytaniu, próbuję usunąć element w tablicy o konkretnym indeksie. Używam metody slice(), jednak nie wiem co jest nie tak, że metoda nie działa...
let myState = getState();
const newActiveChats = JSON.parse(
JSON.stringify(myState.messanger.activeChats)
);
if (newActiveChats.length === 0) return;
const index = newActiveChats.findIndex((chat: IChat) => {
return chat._id === chatId;
});
console.log("index", index);
console.log("before slice", newActiveChats);
newActiveChats.slice(index, 1);
console.log("after slice", newActiveChats);
I konsola :
na konsoli 2 próby usunięcia. Pierwsza elementu o indeksie 0, a druga 1.