Indonesians! Your Hijri Calendar Widget Shouldn't Need a Network Call. So I Fixed That.
Описание и применение
Пакет mabims-hijri позволяет отображать дату по исламскому календарю без сетевых запросов, используя встроенную таблицу данных 2024‑2026 года и обеспечивая быстрый отклик даже в офлайн‑режиме.
Задача
Widgets that display today’s Hijri date make a network request on every render, which is unnecessary for a date that changes only once a day.
Результат
The package eliminates network calls for today’s Hijri date, speeds up widget rendering, works offline, and automatically updates its bundled data in the background.
Рабочий процесс
- Install the package with
npm install mabims-hijri - Import
todayorconvertfrom the package - Call
await today()to get today’s Hijri date (instant, no network) - Use
convertfor Gregorian↔Hijri conversions - For dates outside 2024‑2026, the package falls back to an in‑memory cache and then to the live API
- Set a storage adapter (e.g., AsyncStorage) for persistent caching in React Native
Доказательства
The package ships that table (~72KB of JSON) right inside itself.
For dates outside the bundled range (post‑2026), it falls back gracefully instead of just failing
- Дата записи: 2026-09-08T11:47:19.724Z