I am writing a conditional if else. There's multiple else statements. What is the cleanest way to write it? And the best way to code it down.
PS I am new to reactJS.
if (type === activity.fetchPeople && loading) {
await store.dispatch(fetchPeople(store, 20, 0, params.sectionType));
store.dispatch(showGlobalLoader(false));
} else if (type === activity.pathfallRevert) {
await store.dispatch(fetchactivityfallRevert(store, params.userId, 20, 0));
activityPro = `${labels.pathfallRevert} (${params.count})`;
store.dispatch(showGlobalLoader(false));
} else if (type === activity.pathfall) {
await store.dispatch(fetchactivityfall(store, params.userId, 20, 0));
activityPro = `${labels.pathfall} (${params.count})`;
store.dispatch(showGlobalLoader(false));
} else if (type === activity.road) {
await store.dispatch(fetchRoads(store, params.userId, 20, 0));
activityPro = `${labels.road} (${params.count})`;
store.dispatch(showGlobalLoader(false));
} else if (type === activity.movers) {
await store.dispatch(fetchmovers(store, params.userId, 20, 0));
activityPro = `${labels.movers} (${params.count})`;
store.dispatch(showGlobalLoader(false));
} else {
store.dispatch(showGlobalLoader(false));
}
Thanks
Aucun commentaire:
Enregistrer un commentaire