4 ms·
React 18 is in fact throwing Promises for the new implementation of Suspense working on Server Side Rendering. I found it brilliantly elegant. Throwing a promis
by giorgioz 5y ago
React 18 is in fact throwing Promises for the new implementation of Suspense working on Server Side Rendering.
I found it brilliantly elegant.
Throwing a promise in that context means "I'm not done yet and you should display a fallback"
- d--b 5y agoThis sounds interesting, but very error prone, no? - Some code could throw a legitimate error, that would take the place of the promise. - Some code may catch the promise and treat it as if it was an error.
- pavlov 5y agoThis is in context of React components which are functions but only ever executed by the React runtime itself. So there’s no other code that could catch the promise. And if another component throws an error first, that’s what needs to be handled anyway.