Last active
June 4, 2020 05:54
-
-
Save tofusoup429/cf76b77aff7593d562f53bebed0dcd87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
React.useEffect(()=>{ | |
let openRequest = indexedDB.open("testingIndexedDB", 1); | |
openRequest.onupgradeneeded = function() { | |
// triggers if the client had no database or the client has a higher version | |
// ...perform initialization... | |
console.log("onupgradeneeded"); | |
let db = openRequest.result; | |
console.log(db) | |
}; | |
openRequest.onerror = function() { | |
console.error("Error", openRequest.error); | |
}; | |
openRequest.onsuccess = function() { | |
let db = openRequest.result; | |
console.log(db); | |
console.log('database is ready'); | |
// continue to work with database using db object | |
}; | |
},[]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment