title: React: apply multiple filters to array
body: <p>I'm starting with react and I have an array of objects called arrayToFilter I want to apply multiple filters to, ideally when a user changes the filter select options all filters should be applied to the array and the results returned into a filteredResults array to show, I already have each filter function and their constants but I don't know how to apply all the filters one after another...</p>
  <p>Here is my code:</p>
  <pre><code>    const [ arrayToFilter, setArrayToFilter ] = useState([ /*array of objects to apply filters to*/ ]);
      const [ filteredResults, setFilteredResults] = useState([ /*array of filtered objects*/ ]);
      const [ categoryOptions, setCategoryOptions ] = useState([ 1,2,3 ]);
      const [ selectedCategoryOptions, setSelectedCategoryOptions ] = useState([ ]);
      const [ searchName, setSearchName ] = useState('');
      const [ hideVenuesWithoutDiscounts, setHideVenuesWithoutDiscounts ] = useState(true);
  
      const filterHideVenuesWithoutDiscounts = () =&gt; 
      {
          if(hideVenuesWithoutDiscounts)
          {
              return arrayToFilter.filter(item =&gt; item.discounts.length &gt; 0);
          }
          else
          {
              return arrayToFilter;
          }   
      };
  
      const filterSelectedCategoryOptions = () =&gt; 
      {
          return arrayToFilter.filter(item =&gt; item.category_id.includes(selectedCategoryOptions));
      };
  
      const filtersearchName = () =&gt; 
      {
          return arrayToFilter.filter(item =&gt;  item.name.toLowerCase().indexOf(searchTerm.toLowerCase()) != -1);
      };
  
      useEffect(() =&gt; 
      {
          //Filter options updated so apply all filters here
      },
      [searchName, hideVenuesWithoutDiscounts, selectedCategoryOptions]);
  </code></pre>
  <p>Notice useEffect, afaik this is like watch property in vue, I'd like to fire all the filters when a filter input changes</p>