andreiduca/use-async-resource

Get a `loading` property?

Closed this issue · 1 comments

Hi, first of all thanks for this library, it's great.

I'm working with React Native and I would need a loading boolean to make ScrollView RefreshControl work.

I tried the useTransition hook but it doesn't seem to do what I need.

const [refreshing, startTransition] = useTransition();
const refresh = useCallback(() => {
  resourceCache(stuffLoader).clear();
  startTransition(() => {
    getStuff();
  });
}, []);

I don't think I can get away with suspense in this case, is there any escape hatch to get a simple boolean?

nm! it actually works, but I was passing the wrong argument to resourceCache, that should be the async function itself, the one passed to useAsyncResource.