Replies: 1 comment 4 replies
-
function loader() {
return defer({
values: Promise.all([getCategories(), getCart(), getProducts(), getCities()],
});
}
function Component() {
let { values } = useLoaderData();
return (
<Suspense>
<Await resolve={values}>
{([categories, cart, products, cities]) =>
<Products
products={products}
cart={cart}
categories={categories.data}
cities={cities}
/>}
</Await>
</Suspense>
);
} |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When I have a component that depends on multiple deferred values, then my code starts to have many levels of nesting that I don't really like. For example, see code snippet below
And I really prefer to have code that looks like this
Even though It is possible to create
<AwaitAll>
component based on existent API. It wasn't obvious to me in the beginning. I suspect I'am not the only one.If there is a simpler solution, then I will be grateful for the help
Beta Was this translation helpful? Give feedback.
All reactions