Image caching:
1import FastImage from "react-native-fast-image";23<FastImage4 source={{5 uri: "https://example.com/image.jpg",6 priority: FastImage.priority.normal,7 cache: FastImage.cacheControl.immutable,8 }}9 style={{ width: 200, height: 200 }}10/>
Data caching:
1import AsyncStorage from "@react-native-async-storage/async-storage";23async function cacheData(key: string, data: any, ttl: number) {4 const cached = {5 data,6 timestamp: Date.now(),7 ttl,8 };9 await AsyncStorage.setItem(key, JSON.stringify(cached));10}1112async function getCachedData(key: string) {13 const raw = await AsyncStorage.getItem(key);14 if (!raw) return null;15 const { data, timestamp, ttl } = JSON.parse(raw);16 return Date.now() - timestamp < ttl ? data : null;17}
Libraries:
react-native-fast-image@tanstack/react-query for API caching