Skip to content

Instantly share code, notes, and snippets.

@thatisuday
Last active April 17, 2022 02:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thatisuday/6b2736545e8ab81bc2dfc93e0e7e7553 to your computer and use it in GitHub Desktop.
Save thatisuday/6b2736545e8ab81bc2dfc93e0e7e7553 to your computer and use it in GitHub Desktop.
React Suspense try/catch analogy
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