I want to filter content based on the input typed, I don't know where did I go wrong. Whenever I typed my input it just doesn't filter the content instead of that it is showing all the content there.
function searchingFor(searchingTerm) {
return function(x){
console.log("searching",x);
return x.name.toLowerCase().includes(searchingTerm.toLowerCase())|| searchingTerm;
}
}
class Main extends React.Component{
componentWillMount(){
this.props.fetchTopicsTableContent(this.state.sortBy,'ASC',0,this.props.match.params.Occupation).then(result=> (this.setState({rows:result.payload.data})))
this.props.countTableContent(this.props.match.params.Occupation).then(result=>(this.setState({count:result.payload})));
}
constructor(props){
super(props);
this.state={
searchTerm:"",
rows:""
}
}
searchHandler(e){
this.setState({searchTerm:e.target.value})
// console.log("rows",this.state.rows)
{this.state.rows.filter(searchingFor(this.state.searchTerm)).map(item=>{
console.log(item);
// this.setState({rows:item})
})}
}
render(){
return(
<form>
<input type="text"
value={this.state.searchTerm}
onChange={this.searchHandler.bind(this)}
/>
</form>);}}
map? and are you suresearchingFor()returns true results ?filter(searchingFor(e.target.value)