I am doing a comparison by converting my text to lowercase and comparing its index to -1, in order to have some value to the particular field in ReactJS
, but I am getting this error in JavaScript console:
Uncaught TypeError: props.filterText.toLowerCase is not a function
var props = this.props;
var rows = this.props.episodes
.filter(function(episode){
return episode.title.toLowerCase().indexOf(props.filterText.toLowerCase()) > -1;
})
.map(function(episode){
return <EpisodeRow key={episode.title} episode={episode}/>
});
episode.title
a String? try episode.title.toString().toLowerCase() or console.log its' value to the console. – Tondatoneprops.filterText
is not a string. Just do aconsole.log
inside your filter loop ofprops.filterText
and you'll see it's not a string. My guess is that it will beundefined
– Lipolysis.toLowerCase()
in a loop every time if you don't have to?var filter = props.filterText.toLowerCase()
outside your filter function and doindexOf(filter)
inside your function. – Lipolysisundefined
it's just something that's not a string. Could be a function, number, boolean, but not a string. – Lipolysis