title: Mithril component not updating when route changes
body: <p>I am creating my personal website/blog as a a single page application using Mithril.js. All pages and blog posts on my website are rendered using <code>Page</code> and <code>Post</code> components, and the correct page is loaded based on the <code>:slug</code> in the URL.</p>
  
  <p>The problem I have is that <strong>whenever I try and switch between pages, the content of the page does not update</strong>. Switching between <em>pages and posts</em> works because I am alternating between <code>Page</code> and <code>Post</code> components. But when I try and use the same component twice in a row, going from <em>page to page</em>, it doesn't update the webpage.</p>
  
  <pre><code>m.route(document.body, '/', {
    // `Home` is a wrapper around `Page`
    // so I can route to `/` instead of `/home`
    '/': Home,
    '/:slug': Page,
    '/blog/:slug': Post
  });
  </code></pre>
  
  <pre><code>const Home = {
    view() {
      return m(Page, { slug: 'home' });
    }
  };
  </code></pre>
  
  <p>Here is the <code>Page</code> component (the <code>Post</code> component is very similar). Both components render correctly.</p>
  
  <pre><code>const Page = {
    content: {},
    oninit(vnode) {
      m.request({
        method: 'GET',
        url: 'content.json',
      }).then((response) =&gt; {
        Page.content = response.pages[vnode.attrs.slug];
      });
    },
    view() {
      if (Page.content) {
        return [
          m('#content', m.trust(Page.content.body))
        ];
      }
    }
  };
  </code></pre>
  
  <p>Why isn't Mithril recognizing that the slug changed?</p>