4 ms·
Have you seen React Server Components? You mark a component as `async`, and then you `await` some Promise inside of the component to fetch data. The fallback po
by leerob 3y ago
Have you seen React Server Components? You mark a component as `async`, and then you `await` some Promise inside of the component to fetch data. The fallback points are declaratively defined through React Suspense. For example:
<Suspense fallback={<LoadingSkeleton />}>
<MyComponent />
</Suspense>
Where your Server Component then looks as follows:
async function MyComponent() {
const data = await db.get('...')
return ...
}
https://nextjs.org/docs/getting-started/react-essentials https://nextjs.org/docs/getting-started/react-essentials
- yazaddaruvala 3y agoYes, aware. Its cool, but the ergonomics feel very much the way I felt about Node.js with callbacks. There is a different type of delight that comes from the ergonomics on async/await. This is the big jump React Suspense also needs to make. I am not smart enough to suggest anything here tho. I just know the framework (including React) that can give me that async/await delight while using Suspense will dominate!