title: ReactJS - Search/Iterate through array of objects
body: <p>I have an object like that:</p>
  
  <pre><code>{
    "data": [
      {
        "id": "1234",
        "is_deleted": false,
        "name": "Sarah"
      },
      {
        "id": "3520",
        "is_deleted": true,
        "name": "Bobby"
      },
      {
        "id": "3520",
        "is_deleted": true,
        "name": "Sartah"
      }
    ]
  }
  </code></pre>
  
  <p>React code</p>
  
  <pre><code>import React from 'react';
  import { Input } from 'antd';
  import { connect } from 'dva';
  
  const Search = Input.Search;
  
  @connect(({ rule, loading }) =&gt; ({
    rule,
    loading: loading.models.rule,
  }))
  
  export default class SearchBox extends React.Component {
      constructor(props) {
          super(props)
          this.state = {
              isListLoaded: false,
              resultArr: {}
          }
      }
  
      performSearch(value) {
      for( var i = this.props.rule.data.list.length; i--; ) {
          for (var key in this.props.rule.data.list[i]) {
              this.setState({resultArr: this.state.resultArr.push(i)});
              }
      }
      }
  
      componentDidMount() {
          if (!this.state.isListLoaded) {
              const { dispatch } = this.props;
              dispatch({
                  type: 'rule/fetch'
              });
              this.setState({ isListLoaded: true });
      }
    }
  
    render() {
      return (
        &lt;div&gt;
             &lt;Search
              placeholder="Search..."
                      onChange={(event) =&gt; this.performSearch(event.target.value)}
              style={{ width: "250px", "margin-left": "20px"}}
            /&gt;
        &lt;/div&gt;
      );
    }
  }
  </code></pre>
  
  <blockquote>
    <p>My goal is very simple: I want to search through this object, and
    return the entire array(s) that contains the keyword.</p>
  </blockquote>
  
  <p>Example: if I search "Sar", I should get 2 objects:</p>
  
  <pre><code>{
    "id": "1234",
    "is_deleted": false,
    "name": "Sarah"
  },
  {
    "id": "3520",
    "is_deleted": true,
    "name": "Sartah"
  }
  </code></pre>
  
  <p>Problem is, I get an error when I'm trying this code. I did search for previous solutions to this problem here on SO, but I can only find examples where there's only one element returned. What I want, is to get <strong>ALL</strong> the results that contain the keyword in <strong>ANY</strong> attributes (in this example, I'm returning 2 elements, not just one)</p>
  
  <p>Any idea?</p>