Skip to content

Commit

Permalink
fix useLastEventCallCache update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
joakbjerk authored and tujoworker committed Nov 7, 2024
1 parent 41bf2cc commit beb50ab
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react'
import { useState } from 'react'
import { DatePickerDates } from './useDates'

export type LastEventCallCache = {
Expand All @@ -13,15 +13,13 @@ export default function useLastEventCallCache(
) {
const [cache, setCache] = useState<LastEventCallCache>(undefined)

useEffect(() => {
if (
cache &&
(cache.startDate !== uncachedDates.startDate ||
cache.endDate !== uncachedDates.endDate)
) {
setCache(undefined)
}
}, [uncachedDates, cache])
if (
cache &&
(cache.startDate !== uncachedDates.startDate ||
cache.endDate !== uncachedDates.endDate)
) {
setCache(undefined)
}

return [cache, setCache] as const
}

0 comments on commit beb50ab

Please sign in to comment.