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 nameservices
, 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
objecttoLowerCase
here
ser =>ser.toLowerCase()
which needs to be changed toservices.filter(({ser}) => ser.toLowerCase().slice(0, inputLength) === inputValue);