title: How to check id IndexedDB already exist inside of React lifecycle methods
body: <p>I have react.js component where I want to check if <code>IndexedDB</code> exists. </p>
  
  <p>I am trying to do this </p>
  
  <pre><code>componentDidMount() {
      var dbExists = true;
      var openReq = indexedDB.open("dbName");
      openReq.onupgradeneeded = e =&gt; {
        e.target.transaction.abort();
        dbExists = false;
  
        console.log("Does not exist");
        this.setState({redirect: false})
      };
  
      if (dbExists) {
        this.setState({redirect: true})
      }
    }
  </code></pre>
  
  <p>But it does not work as expected - even if <code>IndexedDB</code> with name <code>dbName</code> exists it shows this line <code>console.log("Does not exist");</code>
  Would you be so kind to give me any advice about <strong>how to check if DB exists</strong> ? 
  <br>
  Thank you in advanced!</p>