title: Using client side search in react
body: <p>Search function is working perfectly fine in the console log but when I try to assign that value to rows which is a state. So I setState the rows inside the setState in searchHandler. I know I'm making a mistake but I don't know how to rectify it. OMIT THE UNDECLARED STATES, MINIFIED THE CODE TO WHAT'S NEEDED</p>
  
  <pre><code>function searchingFor(searchingTerm) {
          return function(x){
              // console.log("searching",x);
              return x.name.toLowerCase().includes(searchingTerm.toLowerCase())|| false;
          }
      }
  
      class Main extends React.Component{
  
          componentWillMount(){
              this.props.fetchTopicsTableContent(this.state.sortBy,'ASC',0,this.props.match.params.CategoryName).then(result=&gt; (this.setState({rows:result.payload.data})))
              this.props.countTableContent(this.props.match.params.CategoryName).then(result=&gt;(this.setState({count:result.payload})));
          }
  
          constructor(props){
              super(props);
  
              this.state={
                  rows:"",
                  searchTerm:"",
                  items:""
              }
          }
  
          onSubmit(values){
              values.preventDefault();
  
          }
  
          onSearchHandler(e){
              this.setState({searchTerm:e.target.value},()=&gt;{
                  {this.state.rows.filter(searchingFor(this.state.searchTerm)).map(item=&gt;{
                      console.log(item);
                       //this.setState({rows:item})
                  })}
              })
          }
  
          render(){
              return(
                  &lt;div&gt;
                      &lt;h3&gt;Topics&lt;/h3&gt;
                      &lt;hr/&gt;
                      &lt;div&gt;
                          &lt;form onSubmit={this.onSubmit.bind(this)}&gt;
                              &lt;input type="text"
                                     className="searchBar"
                                     value={this.state.searchTerm}
                                     onChange={this.onSearchHandler.bind(this)}
                              /&gt;
                          &lt;/form&gt;
                     &lt;/div&gt;
                 &lt;/div&gt;
               )
          }
  </code></pre>