TypeError: Action failed: [component.find(...).filter is not a function]

635 Views Asked by At

Getting TypeError: Action failed: [component.find(...).filter is not a function] in below code

isFormValid: function (component) {
    
    return (component.find('requiredField'))
   .filter(function (i) {
        var value = i.get('v.value');
        console.log('Emailissue' + value);
        return !value || value == '' || value.trim().length === 0;
    })
    .map(function (i) {
        return i.get('v.fieldName');
    });
    
},
1

There are 1 best solutions below

2
On

Do you display the field(s) conditionally? Wrapper in <aura:if isTrue=...> tag maybe? Your find returned a single record with that aura:id (so there's no "filter" on it, it's a single object, not an array) or it haven't found anything at all.

Go to setup -> debug mode, enable it for yourself and add debugger; to this code (or add a watch/breakpoint from the browser's F12 console)