Quantcast
Channel: Type Error in filter function - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Pritish Vaidya for Type Error in filter function

$
0
0

Assuming that your json file is as shown here, there are two problems with your code.

  • Destructuring is wrong. Since you're directly importing an object from a json file as name services, which has not been assigned to any named constant / variable, therefore it cant be destructured.

Therefore you must change the code as

import services from './services.json';

componentDidMount(){
      this.setState({services});
  }
  • You're trying to convert a service object toLowerCase here
    ser =>ser.toLowerCase() which needs to be changed to

    services.filter(({ser}) => ser.toLowerCase().slice(0, inputLength) === inputValue);
    

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>