title: With React hooks how to update 2 hooks together, but use prevState of one in other
body: <p>In the code below, when I call <code>_toggleSearch</code> I update 2 hooks simultaneously.</p>
  
  <p><code>toggleSearchIsVisible</code> is a simple boolean, however, <code>setActiveFilter</code> hook must pass in the previous <code>searchIsVisible</code> state.</p>
  
  <p>How can I be sure the other state hasn't updated yet when passed in? Or how else should I restructure everything? Previously with <code>setState</code> I could've passed in the previous state easily.</p>
  
  <pre><code>const [activeFilter, setActiveFilter] = useState('SHOW_ALL');
  const [searchIsVisible, toggleSearchIsVisible] = useState(false);
  
  const _toggleSearch = () =&gt; {
    setActiveFilter(searchIsVisible ? 'SHOW_SEARCH' : 'SHOW_ALL');
    toggleSearchIsVisible(!searchIsVisible);
  };
  </code></pre>
  
  <p>I've gone with this for now:</p>
  
  <pre><code>const _toggleSearch = () =&gt; {
    if (searchIsActive) {
      setActiveFilter('SHOW_ALL');
      toggleSearchIsActive(false);
    } else {
      setActiveFilter('SHOW_SEARCH');
      toggleSearchIsActive(true);
      updateSearchValue('');
    }
  };
  </code></pre>
  
  <p>Any other suggestions appreciated!</p>