An offline-first health and wellness application featuring custom glassmorphic vitals telemetry, metabolic engines, macro nutrition tracking, and gamified quest rewards.
In initial architectures, logging hydration or logging food re-rendered the entire root DOM tree, dropping frame rates below 30 FPS and causing severe input lag.
Refactored state layers to Zustand selector hooks with useShallow. Decoupled widgets so that data changes stream exclusively to subscribed tiles while the rest of the application remains idle.
Users in low-connectivity environments lost health logs, and background device sync often pushed duplicate entries into cloud databases.
Implemented MMKV key-value caching layer with unique UUID event hashing. Mutations queue locally and synchronize gracefully to Supabase with automatic conflict resolution upon network recovery.
// Zustand Shallow Selector Hook for 60 FPS Telemetry Execution
import { useMemo } from "react";
import { useFitnessStore } from "@/store/fitnessStore";
import { useShallow } from "zustand/react/shallow";
import { getBMIResult, getIdealWeightRange } from "../utils/bmiCalculator";
export function useBMIScreen() {
const store = useFitnessStore(
useShallow((state) => ({
user: state.user,
weightLogs: state.weightLogs,
stepsCount: state.stepsCount,
waterLogs: state.waterLogs,
setUser: state.setUser,
}))
);
const { user } = store;
const currentBMI = useMemo(() => {
return user.weight / ((user.height / 100) * (user.height / 100));
}, [user.weight, user.height]);
const bmiResult = useMemo(() => {
return getBMIResult(user.weight, user.height);
}, [user.weight, user.height]);
const idealRange = useMemo(() => {
return getIdealWeightRange(user.height);
}, [user.height]);
return { user, currentBMI, bmiResult, idealRange };
}