mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 04:50:59 +00:00
Theme provider now initializes to the SSR-stable default and reconciles the stored preference in a mount effect instead of reading localStorage in the useState initializer — closes the same React #418 hydration seam the sidebar already fixed (the inline script still handles the pre-paint class, so no FOUC). Add a process-wide Intl formatter cache and route the per-row workout/medication list helpers through it so a formatter is constructed once per (locale, options) rather than once per row per render.
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
/**
|
|
* Process-wide cache for `Intl.NumberFormat` / `Intl.DateTimeFormat`
|
|
* instances, keyed by locale + options.
|
|
*
|
|
* Constructing an `Intl.*` formatter is comparatively expensive; several
|
|
* list-item helpers built one per row per render (`workout-list`,
|
|
* `recent-workouts-tile`, `medication-card`, …). These getters return a cached
|
|
* instance so the construction cost is paid once per distinct (locale, options)
|
|
* shape instead of once per call. Formatters are immutable + stateless, so
|
|
* sharing a single instance across calls is safe.
|
|
*
|
|
* Keyed by `locale + " |