Search a title or topic

Over 20 million podcasts, powered by 

Player FM logo
Artwork

Content provided by Kent C. Dodds. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Kent C. Dodds or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://podcastplayer.com/legal.
Player FM - Podcast App
Go offline with the Player FM app!

How far can nested UI loaders go for UIs with list of components

7:37
 
Share
 

Manage episode 505989096 series 2982717
Content provided by Kent C. Dodds. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Kent C. Dodds or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://podcastplayer.com/legal.

the UI at https://nothing.tech/products/phone-3 renders a list of "widgets". I would like each of these widgets to have their own loaders to maximise page speed, furthermore I'd be able to "deeplink" a user straight into a widget. But how do I do that when a route can only have one Outlet?

Here's an example with Promise.all. Before:

// routes/dashboard.tsx export async function loader() { const user = await fetch('/api/user').then(r => r.json()) const projects = await fetch(`/api/projects?userId=${user.id}`).then(r => r.json()) const notifications = await fetch(`/api/notifications?userId=${user.id}`).then(r => r.json()) return { user, projects, notifications } }

After:

export async function loader() { const userPromise = fetch('/api/user').then(r => r.json()) const projectsPromise = userPromise.then(user => fetch(`/api/projects?userId=${user.id}`).then(r => r.json()) ) const notificationsPromise = userPromise.then(user => fetch(`/api/notifications?userId=${user.id}`).then(r => r.json()) ) const [user, projects, notifications] = await Promise.all([ userPromise, projectsPromise, notificationsPromise, ]) return { user, projects, notifications } }

Kent's notes:

I forgot that defer is now unnecessary, simply return an object from your loader and any properties on that object that are promises will be sent along as deferred data automatically. Learn more from the links below.

How far can nested UI loaders go for UIs with list of components
  continue reading

222 episodes

Artwork
iconShare
 
Manage episode 505989096 series 2982717
Content provided by Kent C. Dodds. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Kent C. Dodds or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://podcastplayer.com/legal.

the UI at https://nothing.tech/products/phone-3 renders a list of "widgets". I would like each of these widgets to have their own loaders to maximise page speed, furthermore I'd be able to "deeplink" a user straight into a widget. But how do I do that when a route can only have one Outlet?

Here's an example with Promise.all. Before:

// routes/dashboard.tsx export async function loader() { const user = await fetch('/api/user').then(r => r.json()) const projects = await fetch(`/api/projects?userId=${user.id}`).then(r => r.json()) const notifications = await fetch(`/api/notifications?userId=${user.id}`).then(r => r.json()) return { user, projects, notifications } }

After:

export async function loader() { const userPromise = fetch('/api/user').then(r => r.json()) const projectsPromise = userPromise.then(user => fetch(`/api/projects?userId=${user.id}`).then(r => r.json()) ) const notificationsPromise = userPromise.then(user => fetch(`/api/notifications?userId=${user.id}`).then(r => r.json()) ) const [user, projects, notifications] = await Promise.all([ userPromise, projectsPromise, notificationsPromise, ]) return { user, projects, notifications } }

Kent's notes:

I forgot that defer is now unnecessary, simply return an object from your loader and any properties on that object that are promises will be sent along as deferred data automatically. Learn more from the links below.

How far can nested UI loaders go for UIs with list of components
  continue reading

222 episodes

All episodes

×
 
Loading …

Welcome to Player FM!

Player FM is scanning the web for high-quality podcasts for you to enjoy right now. It's the best podcast app and works on Android, iPhone, and the web. Signup to sync subscriptions across devices.

 

Copyright 2025 | Privacy Policy | Terms of Service | | Copyright
Listen to this show while you explore
Play