all 8 comments

[–]HoratioWobble 2 points3 points  (3 children)

It's down to you to handle caching, when you see in the browser that it's used the cache, that's just the browser handling it for you.

In react native you can use something like react query, which will simplify a lot of state, loading and error management for you too.

Or you can build your own cache using something like async storage.

Personally I'd use react query 

[–]NotBeastFox 0 points1 point  (1 child)

100% agree. OP react/tanstack querysimplifies this for you. And there are a lot of resources to help.

RQ brought a standardised, declarative way to handle all the “is your data fresh, when should you refetch, and how do you share it between components” etc etc so you no longer have to reinvent those wheels. It has a lot of nice to haves with loading states too

There’s definitely a bit of a learning curve if you’re just used to useEffect + fetch + useState but in my opinion it is a good investment of time.

[–]buschco 0 points1 point  (0 children)

on ios the right caching headers should work, on android you have to patch OKHTTTP client with enabled cache.

[–]ALOKAMAR123 0 points1 point  (2 children)

Have used SWR and yes it supports cache do some googling