I have a forEach loop which checks if a certain attribute of data coming in includes '/' if it does im replace the '/' with '-', i was wondering if that is valid redux code or im creating some sort of anti-pattern code right here.
case actions.GET_PRODUCTS: {
const data = { ...payload };
data.forEach(item => {
item.options.forEach(option => {
if (option.includes('/')) {
option.cleanVersion = option.replace('/', '-');
}
});
});
return {
...state,
items: data,
};
}
Or could i use something along the lines of normalizr to handle this? and if so an example would be appreciated