score:5

Accepted answer

It looks like locations is a simple Javascript object from JSON. Are you looking for a specific key? If so, I'd go with o => o[this.state.query]. If you're looking for the title match, I'd go with o => o.title.contains(this.state.query) or even better, make it case insensitive with o => o.title.toLowerCase().contains(this.state.query.toLowerCase())

score:2

You are calling an array method on a Obj not and array

score:2

You need to check exact property of the object. Contains will work only on strings or simple array, not array of abject. Should try like object.searchingProperty.Constains(searchingText);

score:28

You are calling contains on your location object. Did you mean to check if the title contains the query string?

Try o.title.includes(this.state.query) instead.

contains appears to be deprecated. You should use includes instead.


Related Query

More Query from same tag