being new to redux, I came across the following challenge: I have a filter-list, which must be updated both after the first load of a component, and every time someone changes a dropdown in the top navbar. The filter-list is dependent on another dropdown which is part of my state. A pseudocode is below [1].
I could theoretically duplicate my action dispatch in both Components (the main one and the navbar), but this is bad design of course.
This brings me to the question: Where does one put redux dispatch calls which must access the state themselves? Would this live in the action-file which would then need to access the state itself (which might not be good design on its own)?
Thanks!
[1]
function getDrillOptions() {
let data = props.data; // <- is part of redux' store
let countries = props.selectedFilters.countries; //<- part of redux' store
let regions = getRegionForCountry(countries);
let selectable = new Set();
Object.keys(data[regions][countries]).map((weeknum) => {
data[regions][countries][weeknum].map((row) => {
selectable.add(row[event.target.value]);
});
});
dispatch(populateFilters({filter: 'mainDrillOptions', value: [...selectable]})); // <- sets state
}