XYZ_Cell.js - export const FirstLoad = () => {}

Hey,

One thing I don’t love about the “cells” concept is that if I peel off refetch of the success component export default function Post({post, refetch}) { ... } I’m not always going to want the loading component to be used on the second load, ie would rather the success component show stale data for a couple of seconds at most and update when the request comes back.
Not a big problem, I’ll likely stop using cells for these cases, unless there’s a workaround?

An idea I had as per the subject, is to have an optional FirstLoad export.

Can you make your loading state component smarter and only show “Loading…” if there is no data, and show (stale) data if you’ve already fetched once?

Possibly. I would have to set up some kind of app data store for that right? unless there’s a way for the loading component to access data from the last successful fetch?

There is probably some way to do this by leveraging the cache in Apollo Client. But I don’t know how off the top of my head. The other option is, as you say, to use React state to store it. Either you lift a plain old useState up to some parent, or you store the state in context if you need it in other places as well.

1 Like