title: React trigger useEffect when two things changes
body: <p>I am trying to use react hooks and I want to run a function when two things change:</p>
  
  <pre><code>const Filter = ({ orderList, orders }) =&gt; {
    const [from, setFrom] = useState();
    const [to, setTo] = useState();
    const [filteredList, setFilteredList] = useState(orders);
  
    useEffect(() =&gt; {
      const filteredOrders = orders.filter(function(item) {
        return item.order_number &gt;= from &amp;&amp; item.order_number &lt;= to;
      });
      setFilteredList(filteredOrders);
      console.log(filteredList);
    }, [from, to]);
  </code></pre>
  
  <p>more precisely I would like to filter the array only when BOTH <code>from</code> and <code>to</code> states changes, this is because I am trying to filter an array from some inputs defined by the user.</p>
  
  <p>How can I achieve this? </p>