@attio/react-native-bottom-sheet-toolbox
Version:
16 lines (14 loc) • 502 B
text/typescript
import React from "react"
import {runOnUI} from "react-native-reanimated"
// biome-ignore lint/suspicious/noExplicitAny: not useful to type
export function useWorkletUiCallback<TArgs extends any[]>(fcn: (...a: TArgs) => void, deps: any[]) {
return React.useCallback((...a: TArgs) => {
"worklet"
if (_WORKLET) {
fcn(...a)
} else {
runOnUI(fcn)(...a)
}
// biome-ignore lint/correctness/useExhaustiveDependencies: ignore
}, deps)
}