Answer the question
In order to leave comments, you need to log in
Where in React / Redux / Saga to compare the received data with the store?
I receive data from the server with Ajax - a list of news.
It is necessary to filter from the list only those news that are not yet available and add them.
Here is the Saga code:
function* getNewsUpdate({payload}) {
try {
const response = yield call(getLatestNews,payload.lang);
yield put({type: "LOADED_NEWS", payload: {lang: payload.lang, loadedNews: response}});
} catch (err) {
console.log(err);
}
}
case 'LOADED_NEWS':
let {lang, loadedNews} = action.payload;
let newElements = filterNewItems(state[lang], loadedNews);
return {...state,
[lang]: [...state[lang], ...newElements]
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question