Frontend First cover image

Frontend First

React Deep Dive: useOptimistic

Feb 14, 2024
51:08

Ryan and Sam discuss the purpose and usage of the useOptimistic() hook, a new experimental API from React.

Topics include:

  • 0:00 - Intro
  • 2:18 - Problem: RSCs require a server roundtrip before the UI can be updated
  • 10:13 - Solution: useOptimistic() lets you merge ephemeral client-side state with server-side data so you can update the UI during a Server Action or Transition
  • 14:03 - How useOptimistic() avoids the notion of identity by discarding the ephemeral state after the app settles
  • 21:17 - How useOptimistic() lets you safely “fork” state that eventually syncs with the server
  • 27:32 - Handling error states
  • 29:26 - Differences between useOptimistic() and Remix fetchers
  • 34:57 - How useOptimistic() lets you avoid managing a long-lived client-side cache

Links:

Get the Snipd
podcast app

Unlock the knowledge in podcasts with the podcast player of the future.
App store bannerPlay store banner

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode

Save any
moment

Hear something you like? Tap your headphones to save it with AI-generated key takeaways

Share
& Export

Send highlights to Twitter, WhatsApp or export them to Notion, Readwise & more

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode