I am trying to resolve this TypeError but have not been able to. Below is the code it is pointing to. I have tried assigning a var to it as some other similar posts have mentioned but no luck. ):
const emailReducer = (state, action) => {
if (action.type === 'USER_INPUT') {
return { value: action.val, isValid: action.val.includes('@') }
}
if (action.type === 'INPUT_BLUR') {
return { value: state.value, isValid: state.val.includes('@') }
}
return { value: '', isValid: false };
};
CodePudding user response:
The value of state.val
is undefined
and it's lacking the includes
method. In your code the value should be addressed to as state.value
.