added null checks for communities leaderboard data

This commit is contained in:
Nouman Tahir 2021-08-05 20:34:53 +05:00
parent 2ef52f2292
commit 807174322a
2 changed files with 10 additions and 8 deletions

View File

@ -59,17 +59,19 @@ const TabEmptyView = ({
useEffect(() => {
if (!leaderboard.loading) {
if (!leaderboard.error && leaderboard.data.length > 0) {
_formatRecommendedUsers(leaderboard.data);
const {loading, error, data} = leaderboard;
if (!loading) {
if (!error && data && data.length > 0) {
_formatRecommendedUsers(data);
}
}
}, [leaderboard]);
useEffect(() => {
if (!communities.loading) {
if (!communities.error && communities.data?.length > 0) {
_formatRecommendedCommunities(communities.data);
const {loading, error, data} = communities;
if (!loading) {
if (!error && data && data?.length > 0) {
_formatRecommendedCommunities(data);
}
}
}, [communities]);

View File

@ -69,7 +69,7 @@ export default function (state = initialState, action) {
return {
...state,
communities: {
data: action.payload,
data: action.payload || [],
loading: false,
error: false,
},
@ -96,7 +96,7 @@ export default function (state = initialState, action) {
return {
...state,
subscribedCommunities: {
data: action.payload,
data: action.payload || [],
loading: false,
error: false,
},