Skip to content
Snippets Groups Projects
  • Joel Jeremy Marquez's avatar
    6fae7956
    Some typescript migration (#1532) · 6fae7956
    Joel Jeremy Marquez authored
    * Typescript migration
    
    * Release notes
    
    * Update error boundary
    
    * Breakup sidebar components
    
    * Account and Sidebar props
    
    * Remove button in Item component + exports cleanup
    
    * Put accountNameStyle to Account
    
    * Revert component ports (separated to another PR)
    
    * Export cleanup
    
    * Remove ErrorBoundary (separated to another PR)
    
    * Sidebar budgetName as ReactNode
    Some typescript migration (#1532)
    Joel Jeremy Marquez authored
    * Typescript migration
    
    * Release notes
    
    * Update error boundary
    
    * Breakup sidebar components
    
    * Account and Sidebar props
    
    * Remove button in Item component + exports cleanup
    
    * Put accountNameStyle to Account
    
    * Revert component ports (separated to another PR)
    
    * Export cleanup
    
    * Remove ErrorBoundary (separated to another PR)
    
    * Sidebar budgetName as ReactNode
SyncRefresh.tsx 534 B
import { type ReactNode, useState } from 'react';

type ChildrenProps = {
  refreshing: boolean;
  onRefresh: () => Promise<void>;
};
type SyncRefreshProps = {
  onSync: () => Promise<void>;
  children: (props: ChildrenProps) => ReactNode;
};
export default function SyncRefresh({ onSync, children }: SyncRefreshProps) {
  let [syncing, setSyncing] = useState(false);

  async function onSync_() {
    setSyncing(true);
    await onSync();
    setSyncing(false);
  }

  return children({ refreshing: syncing, onRefresh: onSync_ });
}