title: React useContext not causing a rerender
body: <p>So I am attempting to use a custom hook that utilizes useContext which I would expect to cause a rerender of my ToastContainer component when ToastContext changes. However, the ToastContainer component is not rerendering when the context changes. When using dev tools I can see that the context is indeed changed by the hook, but the new data is not being displayed.</p>
  <p>Sorry for all the code, I'm just not sure where the bug lies</p>
  <p>useToast.js</p>
  <pre class="lang-js prettyprint-override"><code>function useToast () {
    let [toasts, setToasts] = useContext(ToastContext)
    
  
    function createToast(message, color, duration = 0) {
      let id = Math.floor(Math.random() * 1000)
      toasts.set(id, &lt;Toast {...{ message, color, duration, id }} /&gt;)
      setToasts(toasts)
  
      if (duration) {
        setTimeout(() =&gt; { toasts.delete(id); setToasts(toasts)}, duration * 1000)
      }
    }
  
    return [toasts, createToast]
  }
  
  </code></pre>
  <p>ToastContainer.js</p>
  <pre class="lang-js prettyprint-override"><code>function ToastContainer (props) {
    let [toasts, setToasts] = useContext(ToastContext)
    return( &lt;&gt; {[...toasts.values()]} &lt;/&gt;)
  }
  </code></pre>
  <p>page.js</p>
  <pre class="lang-js prettyprint-override"><code>function Page (props) {  
      let [toasts, createToast] = useToast()  
      createToast(&quot;hello&quot;, 'red')
      createToast(&quot;world&quot;, 'yellow')
  
      return(&lt;Article /&gt;)
  }
  </code></pre>
  <p>app.js</p>
  <pre class="lang-js prettyprint-override"><code>function App({Component, pageProps}) {
  
  
    const toastState = useState(new Map())
  
    return (
      &lt;&gt;
            &lt;ToastContext.Provider value={toastState}&gt;
              &lt;ToastContainer/&gt;
              &lt;main&gt;
                  &lt;Component {...pageProps}&gt;&lt;/Component&gt;
              &lt;/main&gt;
            &lt;/ToastContext.Provider&gt;
      &lt;/&gt;
    )
  </code></pre>