title: localForage in react app: self is undefined
body: <p>I'm trying to use <a href="https://localforage.github.io/localForage/" rel="nofollow noreferrer">localForage</a> in a reactjs app. Calling <code>setItem</code> and then <code>getItem</code> works exactly once. The value that was set with <code>setItem</code> is correctly recovered by <code>getItem</code>. If they are called again after that, a <code>TypeError</code> is thrown:</p>
  
  <pre><code>TypeError: self is undefined localforage.js:1012
  </code></pre>
  
  <p>The error can be reproduced with a minimal reactjs app, here's just a single functional component.<br>
  When the component is rendered, it calls <code>setItem</code> and <code>getItem</code>.
  It rerenders on a button click and calls <code>setItem</code> and <code>getItem</code> again. This causes the <code>TypeError</code>.</p>
  
  <pre><code>import React, { useState } from "react";
  import { getItem, setItem } from "localforage";
  
  function App() {
    const [state, setState] = useState(0);
    setItem("test", state).then(() =&gt; {
      console.log("used localForage");
    });
  
    getItem("test").then((val) =&gt; {
      console.log("got: ", val);
    });
    return (
      &lt;button
        onClick={() =&gt; {
          setState(Math.floor(Math.random() * 10));
        }}
      &gt;
        {state}
      &lt;/button&gt;
    );
  }
  
  export default App;
  </code></pre>
  
  <p>Here is an <a href="https://codesandbox.io/s/bold-sun-rl8y3" rel="nofollow noreferrer">online version on codesandbox</a>.</p>