Added loading state for getting data from redux store
This commit is contained in:
parent
4312533d5c
commit
be4587f7cc
@ -20,8 +20,8 @@ const useArticleCommonStore = (): ArticleStore => {
|
|||||||
setError(true);
|
setError(true);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
setLoading(false);
|
|
||||||
setCurrentArticle(fromStore);
|
setCurrentArticle(fromStore);
|
||||||
|
setLoading(false);
|
||||||
return fromStore;
|
return fromStore;
|
||||||
}
|
}
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
@ -17,13 +17,13 @@ const articleReducer = (
|
|||||||
): ArticleStoreState => {
|
): ArticleStoreState => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case actionTypes.SET_ARTICLE:
|
case actionTypes.SET_ARTICLE:
|
||||||
return { ...state, articles: action.updatedList, currentArticle: action.article, hasError: typeof action.article === undefined };
|
return { ...state, articles: action.updatedList, currentArticle: action.article, hasError: typeof action.article === undefined, isLoading: false };
|
||||||
case actionTypes.GET_ARTICLE:
|
case actionTypes.GET_ARTICLE:
|
||||||
return { ...state, isLoading: true };
|
return { ...state, isLoading: true };
|
||||||
case actionTypes.GET_ARTICLE_SUCCESS:
|
case actionTypes.GET_ARTICLE_SUCCESS:
|
||||||
return { ...state, isLoading: false, currentArticle: action.payload };
|
return { ...state, isLoading: false, currentArticle: action.payload };
|
||||||
case actionTypes.GET_ARTICLE_FAILURE:
|
case actionTypes.GET_ARTICLE_FAILURE:
|
||||||
return { ...state, hasError: true, isLoading: false };
|
return { ...state, hasError: false, isLoading: true };
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user