mirror of
https://github.com/actualbudget/actual.git
synced 2026-04-30 18:00:06 -05:00
Do not pass entire react query result to provider because it is not a stable reference
This commit is contained in:
@@ -94,9 +94,9 @@ function SelectedBalance({ selectedItems, account }: SelectedBalanceProps) {
|
||||
|
||||
let scheduleBalance = 0;
|
||||
|
||||
const { data: schedules = [], isPending } = useCachedSchedules();
|
||||
const { data: schedules = [], isLoading } = useCachedSchedules();
|
||||
|
||||
if (isPending) {
|
||||
if (isLoading) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -315,7 +315,7 @@ type PayeeIconsProps = {
|
||||
|
||||
function PayeeIcons({ transaction, transferAccount }: PayeeIconsProps) {
|
||||
const { id, schedule: scheduleId } = transaction;
|
||||
const { isPending: isSchedulesLoading, data: schedules = [] } =
|
||||
const { isLoading: isSchedulesLoading, data: schedules = [] } =
|
||||
useCachedSchedules();
|
||||
const isPreview = isPreviewId(id);
|
||||
const schedule = schedules.find(s => s.id === scheduleId);
|
||||
|
||||
@@ -764,9 +764,9 @@ function PayeeIcons({
|
||||
const { t } = useTranslation();
|
||||
|
||||
const scheduleId = transaction.schedule;
|
||||
const { isPending, data: schedules = [] } = useCachedSchedules();
|
||||
const { isLoading, data: schedules = [] } = useCachedSchedules();
|
||||
|
||||
if (isPending) {
|
||||
if (isLoading) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,12 @@ import type { PropsWithChildren } from 'react';
|
||||
import { useSchedules } from './useSchedules';
|
||||
import type { UseSchedulesProps, UseSchedulesResult } from './useSchedules';
|
||||
|
||||
type SchedulesContextValue = UseSchedulesResult;
|
||||
type SchedulesContextValue = Pick<
|
||||
UseSchedulesResult,
|
||||
'data' | 'isLoading' | 'error'
|
||||
>;
|
||||
|
||||
const SchedulesContext = createContext<SchedulesContextValue | undefined>(
|
||||
undefined,
|
||||
);
|
||||
const SchedulesContext = createContext<SchedulesContextValue | null>(null);
|
||||
|
||||
type SchedulesProviderProps = PropsWithChildren<UseSchedulesProps>;
|
||||
|
||||
@@ -16,9 +17,10 @@ export function SchedulesProvider({
|
||||
children,
|
||||
...props
|
||||
}: SchedulesProviderProps) {
|
||||
const data = useSchedules(props);
|
||||
const { isLoading, data, error } = useSchedules(props);
|
||||
|
||||
return (
|
||||
<SchedulesContext.Provider value={data}>
|
||||
<SchedulesContext.Provider value={{ data, isLoading, error }}>
|
||||
{children}
|
||||
</SchedulesContext.Provider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user