title: useEffect Hook Not Firing After State Change
body: <p>I have two sibling components that share state via context in react.
  The shared state between the components is an array.</p>
  <p>If I update <code>arr</code> state in one component, I want the other component to listen for that update and do something accordingly. When I use <code>useEffect</code> in the second component, I listen for changes in the <code>arr</code> state variable.</p>
  <p>For example:</p>
  <pre><code>// App Component -------
  const App = props =&gt; {
   const { arr, setArr } = useContext(GlobalContext)
    
   const handleChange = () =&gt; {
     const newArr = arr
     [10, 20, 30, 40].map(v =&gt; {
       newArr.push(v)
       setArr(newArr)
     })
  
    return (...)
  }
  
  // App2 (Sibling) Component 
  const App2 = props =&gt; {
    const { arr, setArr } = useContext(GlobalContext)
    const [localArr, setLocalArr] = useState(0)
  
    useEffect(
      () =&gt; {
        updateLocalState()
      },
      // fire if &quot;arr&quot; gets updated
      [arr]
    )
  
    const updateLocalState = () =&gt; {
      setLocalArr(localArr + 1)
    }
  
    return (...)
  }
  </code></pre>
  <p>The <code>useEffect</code> hook is <em>only</em> fired on the initial render, though the state of <code>arr</code> updates.</p>
  <p>I know that declaring a new variable <code>const newArr = arr</code> to my state variable is a reference, so <code>newArr.push(v)</code> is technically a state mutation. <em>However, the state still updates, no warning is thrown, and <code>useEffect</code> does nothing.</em></p>
  <p>Why does <code>useEffect</code> not get called though the state gets updated? Is it because of the state mutation?</p>
  <p>Second Question: Why is there no warning or error thrown regarding a state mutation? State mutations are dangerous - If it happens, I'd expect some sort of warning.</p>
  <p>Live demo here:</p>
  <p><a href="https://codesandbox.io/s/7wzlo8y4m1" rel="noreferrer"><img src="https://codesandbox.io/static/img/play-codesandbox.svg" alt="Edit 7wzlo8y4m1" /></a></p>