Closed tomzaku closed 4 years ago
First, I tried to use this one
const favoritesList = getState().gallery.lists.favorites as string[];
dispatch(
removeFavoriteActionCreators.succeeded({
resources: favoritesList.filter(favoritesId => id !== favoritesId),
mergeListIds: false,
disableUpdatePagination: true
})
);
};
Do you have any better solution?
Hi @tomzaku ! There is an action type UPDATE_RESOURCES
which can be used to update just a list, without affecting the actual resource.
Using it may look like the following:
function removeFromFavorites(favoritesId) {
const favoritesList = getState().gallery.lists.favorites;
const filteredList = favoritesList.filter(id => is !== favoritesId);
dispatch({
type: ‘UPDATE_RESOURCES’,
lists: {
gallery: {
favorites: filteredList
}
}
});
}
You can read more about this action type, and a related action type, DELETE_RESOURCES
, here:
i have a favourite list
Now I would like to remove "1" out of my favourite list without delete the object "1" in resourses object. How can I handle this case