Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Uncaught TypeError: Cannot read properties of undefined (reading 'includes')?

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 };
};

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading