Fix TODO
This commit is contained in:
@@ -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],
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user