This commit is contained in:
Eric Bailey
2026-01-21 21:22:12 -06:00
parent 55825c4f26
commit 942644dee5
-21
View File
@@ -1,21 +0,0 @@
import {useCallback} from 'react'
export enum OnceKey {
PreferencesThread = 'preferences:thread',
}
const called: Record<OnceKey, boolean> = {
[OnceKey.PreferencesThread]: false,
}
// TODO dedupe with runCallbackOnce
export function useCallOnce(key: OnceKey) {
return useCallback(
(cb: () => void) => {
if (called[key] === true) return
called[key] = true
cb()
},
[key],
)
}