Skip to content

v1.0.0

Choose a tag to compare

@SiandjaRemy SiandjaRemy released this 07 Apr 23:44
· 21 commits to main since this release

react-native-cached-flags v1.0.0 — First stable release 🎉

After three releases and real-world usage, the API is stable and production-ready.


What's new in v1.0.0

Request deduplication

Rendering the same flag N times simultaneously now triggers exactly 1 network
request. All instances share the in-flight promise via an internal map and resolve
together when it completes.

// 50 renders → 1 network request
{Array.from({ length: 50 }).map((_, i) => (
  <CountryFlag key={i} isoCode="CM" size={32} useSvg />
))}

Cache TTL — cacheTTLDays

Flags now support optional expiry. Useful for flags that occasionally change
(South Sudan, Kosovo, etc.):

<CountryFlag isoCode="CM" size={32} useSvg cacheTTLDays={90} />

Cache entries now store a JSON payload with a timestamp. Fully backward
compatible — existing raw SVG cache entries from v0.x are read correctly
and migrated to the new format on next save.

onLoad / onError callbacks

<CountryFlag
  isoCode="CM"
  size={32}
  useSvg
  onLoad={() => setReady(true)}
  onError={(msg) => console.error(msg)}
/>

preloadFlags utility

Warm the cache before your screen renders — ideal for country pickers
and onboarding flows. Processes in batches of 10, uses Promise.allSettled
so one failure never aborts the rest:

await preloadFlags(['US', 'CM', 'FR', 'DE', 'JP'], {
  aspectRatio: '4:3',
  ttlDays: 30,
});

Upgrade from v0.2.0

No breaking changes. All existing props and utilities work exactly as before.

npm install react-native-cached-flags@1.0.0

cached-flags-v1-demo