, 10 tweets, 4 min read
My Authors
Read all threads
Wait hold up React fam ✋

A route only needs to block (Suspend) on the initial data, right?

If our Route were to preload its data, and also send down a read() method that got called on every render, and threw until the FIRST data were ready, wouldn’t that be sufficient?

1/
Subsequent data updates (and, well, the initial data) would be returned from the same GraphQL hooks we’re already using, with the same incremental spinners.

But now a single initial page reveal with all needed data. And render as you fetch.

Is there a downside I’m missing?

2/
So something like

const TodoList = (props) => {
// data already prefetching

props.res.read(); //throws if init data not ready

const { loading, data } = useSameOldGraphQLQuery(...);

// and go ...
✅ Prefetch
✅ Suspend initial render until all data ready
✅ Incremental spinner

❌ Really long wait times won’t revert to the <Suspense /> fallback but who cares?
@dan_abramov @sebmarkbage punish me ⛓🚬 and tell me why I’m wrong.

I’m ready
And no twisted, bizarre interactions between components mutating data, and your top-level router.
@dan_abramov @sebmarkbage To put an exclamation mark on this, with existing React clients (any of them)

const { loading, data } = useSameOldGraphQLQuery(...);

if you then mutate some local data on the other side of your app, this 👆 hook will re-fire, on its own, automatically, with updated data.

1/
@dan_abramov @sebmarkbage Without any need to tell the router to create a new resource object, without any manual work whatsoever. Without your GraphQL client needing to know what a Router is, let alone which you're using, or where it is.

It sees data update, and it pushes updates out of the hook
@dan_abramov @sebmarkbage That's what I want to keep, but still get the benefits of those Suspense demo's.

Ideally without boiling the ocean / re-writing everything.
@dan_abramov @sebmarkbage s/
if you then mutate some local data on the other side of your app/
if you then mutate data from the other side of your app/
Missing some Tweet in this thread? You can try to force a refresh.

Enjoying this thread?

Keep Current with Adam Rackis

Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!