-
Joel Jeremy Marquez authored
* MobileBudget tsx * Release notes * Fix type error * Update upcoming-release-notes/2081.md Co-authored-by:
Matiss Janis Aboltins <matiss@mja.lv> * SyncRefresh.tsx * Remove loadCategories --------- Co-authored-by:
Matiss Janis Aboltins <matiss@mja.lv>
Joel Jeremy Marquez authored* MobileBudget tsx * Release notes * Fix type error * Update upcoming-release-notes/2081.md Co-authored-by:
Matiss Janis Aboltins <matiss@mja.lv> * SyncRefresh.tsx * Remove loadCategories --------- Co-authored-by:
Matiss Janis Aboltins <matiss@mja.lv>
SyncRefresh.tsx 542 B
import React, { type ReactNode, useState } from 'react';
type ChildrenProps = {
refreshing: boolean;
onRefresh: () => Promise<void>;
};
type SyncRefreshProps = {
onSync: () => Promise<void>;
children: (props: ChildrenProps) => ReactNode;
};
export function SyncRefresh({ onSync, children }: SyncRefreshProps) {
const [syncing, setSyncing] = useState(false);
async function onSync_() {
setSyncing(true);
await onSync();
setSyncing(false);
}
return <>{children({ refreshing: syncing, onRefresh: onSync_ })}</>;
}