My Redux Store is Like this:
{
data: {
dashboards: {...},
products: {...}
},
globalFilters: {
...
}
}
problem is that when I dispatch dashboards data, fetching data from the backend and update store. Saga:
export function* getDashboards() {
yield takeEvery(constants.GET_DASHBOARDS, function* generator() {
try {
const { data } = yield axios.get('/dashboards', {
params
});
yield put(actions.setDashboards(data));
} catch (e) {
console.log(e);
}
});
export default function* rootSaga() {
yield all([fork(getDashboards)]);
}
reducer:
case constants.SET_DASHBOARDS:
return {
...state,
data: action.payload.data
};
default:
return {
...state
};
all useSelectors are triggered, including useSelectors(state => state.globalFilters) and rerendering all components, which are using any global data. how to solve this?