title: React MultiSelect not working as expected
body: <p>The problem is that when the value of the <code>MultiSelect</code> is not empty, the function that is being called on the <code>filterOptions</code> props of the <code>MultiSelect</code> keeps executing the <code>Http</code> call inside it.</p>
  
  <pre><code>import MultiSelect from "react-multi-select-component";
  ...
  
  
  const [invoices,set_invoices] = useState([]);
  const [selected, setSelected] = useState([]);
  
  function test(options, filter) {
      if (!filter) {
          return options;
      }
      var data={'invoice_number':'22'}
      axios.post('http://localhost:4000/get_invoice_by_number',data).then(
          response =&gt; {
              /* Matching the array elements to be like {lable:'',value:''} */
              var temp_invoices=[];
              for(var i =0;i&lt;response.data.length;i++){
                  temp_invoices.push({
                      label:response.data[i].invoice_number,
                      value:response.data[i].invoice_number
                  })
              }
              /* This is updating the list with response.data that is coming from the API */
              set_invoices(temp_invoices);
              console.log('FIRED')
  
          },error =&gt;{
              console.log(error);
          }
      )
      return options;
  
  }
  
  
  &lt;MultiSelect
      options={invoices}
      value={selected}
      labelledBy={"Select"}
      onChange={setSelected}
      filterOptions={test}
  /&gt;
  </code></pre>
  
  <p><strong>The console.log shows this when i just type one letter in the input</strong></p>
  
  <p><a href="https://i.stack.imgur.com/eFbhb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eFbhb.png" alt="This what happen when i type inside the MultiSelect input"></a></p>
  
  <p>I tried to remove <code>set_invoices(temp_invoices);</code> from the <code>test function</code> and tried to type it only showed <code>FIRED</code> two times and only when typing.</p>
  
  <p>I have been stuck on this since hours and not figuring out the problem. Any help is much appreciated.</p>