Last active
April 17, 2022 02:20
-
-
Save thatisuday/6b2736545e8ab81bc2dfc93e0e7e7553 to your computer and use it in GitHub Desktop.
React Suspense try/catch analogy
This file contains hidden or 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
const a = () => {throw new Error('Oops!')}; | |
const b = () => a(); | |
const c = () => b(); | |
try { | |
try { | |
c(); | |
console.log('Child worked.'); | |
} catch (e) { | |
console.log("Error inside child", e?.message); | |
} | |
console.log('Parent worked.'); | |
} catch (e) { | |
console.log("Error inside parent", e?.message); | |
} | |
// Error inside child Oops! | |
// Parent worked. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment