I am currently having an issue adding/reducing to an array via redux. Just to make sure my redux state works, i hard coded values in and it triggers every time i press a button.
Code that works:
import * as actionType from '../actions/ActionType';
const counterReducer = (state = [], action) => {
let newState = [];
switch (action.type) {
case actionType.ADD_FILTER:
if (!state.includes(action.payload)) {
return newState = ['test'];
}
return newState = ['test'];
default:
return state;
}
};
export default counterReducer;
Code that doesnt trigger a rerender:
import * as actionType from '../actions/ActionType';
const counterReducer = (state = [], action) => {
let newState = [];
switch (action.type) {
case actionType.ADD_FILTER:
if (!state.includes(action.payload)) {
const current = state;
current.push(action.payload);
return newState = current;
}
return newState = state;
default:
return state;
}
};
export default counterReducer;
The redux store however updates? Help?