title: Setting a useEffect hook's dependency within`useEffect` without triggering useEffect
body: <p>Edit: It just occurred to me that there's likely no need to reset the variable within the <code>useEffect</code> hook. In fact, <code>stateTheCausesUseEffectToBeInvoked</code>'s actual value is likely inconsequential. It is, for all intents and purposes, simply a way of triggering <code>useEffect</code>.</p>
  
  <p>Let's say I have a functional React component whose state I initialize using the <code>useEffect</code> hook. I make a call to  a service. I retrieve some data. I commit that data to state. Cool. Now, let's say I, at a later time, interact with the same service, except that this time, rather than simply retrieving a list of results, I CREATE or DELETE a single result item, thus modifying the entire result set. I now wish to retrieve an updated copy of the list of data I retrieved earlier. At this point, I'd like to again trigger the <code>useEffect</code> hook I used to initialize my component's state, because I want to re-render the list, this time accounting for the newly-created result item.</p>
  
  <p>&#x200B;</p>
  
  <pre><code>const myComponent = () =&gt; {
    const [items, setItems] = ([])
    useEffect(() =&gt; {
      const getSomeData = async () =&gt; {
        try {
          const response = await callToSomeService()
          setItems(response.data)
          setStateThatCausesUseEffectToBeInvoked(false)
        } catch (error) {
          // Handle error
          console.log(error)
        }
      }
    }, [stateThatCausesUseEffectToBeInvoked])
  
    const createNewItem = async () =&gt; {
      try {
        const response = await callToSomeService()
        setStateThatCausesUseEffectToBeInvoked(true)
      } catch (error) {
          // Handle error
          console.log(error)
      }
    }
  }
  </code></pre>
  
  <p>&#x200B;</p>
  
  <p>I hope the above makes sense.</p>
  
  <p>&#x200B;</p>
  
  <p>The thing is that I want to reset <code>stateThatCausesUseEffectToBeInvoked</code> to <code>false</code> WITHOUT forcing a re-render. (Currently, I end up calling the service twice--once for win <code>stateThatCausesUseEffectToBeInvoked</code> is set to <code>true</code> then again when it is reset to <code>false</code> within the context of the <code>useEffect</code> hook. This variable exists solely for the purpose of triggering <code>useEffect</code> and sparing me the need to elsewhere make the selfsame service request that I make within <code>useEffect</code>.</p>
  
  <p>&#x200B;</p>
  
  <p>Does anyone know how this might be accomplished?</p>