title: Filter array based on multiple filters
body: <p>I have a table that I want to be able to apply multiple filters to. My current code will filter by email OR status but I want it to do both so a user can refine the results.</p>
  <p>I've tried adding <code>&amp;&amp;</code> instead of <code>||</code> in the <code>filteredInvoices</code> variable.</p>
  <p>I allow the user to select the filters they want to use and store this in an object in useState. I also keep track of the status if the filter is active or inactive.</p>
  <pre><code>const [filter, setFilter] = useState({active: false})
  </code></pre>
  <p>A filter object where a user has selected their filters would look like this:</p>
  <pre><code>filter: {active: true, customerEmail: 'johndoe@gmail.com', status: 'open'}
  </code></pre>
  <p>When a user applies this filter to the table I call a function called <code>updateFilter()</code> in useEffect when the filter is changed. This will then set the filtered array to state when is then iterated over in the <code>return</code>.</p>
  <pre><code>const updateFilter = () =&gt; {
      const filteredInvoices = invoices.filter((inv) =&gt; {
          const emailMatch = filter.customerEmail &amp;&amp; inv.customerEmail.toLowerCase().includes(filter.customerEmail.toLowerCase())
          const statusMatch = inv.status === filter.status
          return emailMatch || statusMatch
      })
      setListToRender(filteredInvoices)
  }
  
  useEffect(() =&gt; {
      if (filter.active) {
          updateFilter()
      }
  
  }, [filter])
  </code></pre>
  <p>The status that is being filtered is an array of objects.</p>
  <p>How am I able to filter by multiple condiitions that are added into the filter object?</p>
  <p>Is there a common design for this that would allow me to add additional filters to the filter object and it also work?</p>
  <p>For example - johndoe@gmail.com has 10 invoices - 3 open, 4 paid and 3 void. If the filter object looks like this:</p>
  <p>How can I filter to show only invoices for that customer that are open.</p>
  <p>Thanks in advance for any advice!</p>