title: Window.scroll only working once (React.js)
body: <p>I'm making a simple React component to remember where you are on the page and place you there when returning.</p>
  <p>Here's the code:</p>
  <pre><code>function ScrollCache() {
    window.scroll(0, parseInt(localStorage['scroll']));
    document.addEventListener('scroll', function (e) {
      if (window.scrollY != 0) {
        localStorage['scroll'] = window.scrollY.toString();
      }
    })
    return (&lt;&gt;&lt;/&gt;)
  }
  </code></pre>
  <p>Basically, it caches the last known scroll position, and uses <code>window.scroll(x, y)</code> to scroll to that position. I have verified that localStorage is working as intended with a <code>console.log</code> immediately before the <code>window.scroll</code>. I've also just tried a static <code>100</code> for the y coordinate. No matter what, it only scrolls once at reload and then never again when I'm navigating around.</p>
  <p>I'm using React Router to go between web pages. Any help is appreciated</p>