INNER CODE UNIT · TypeScript
runOnce
terrysahaidak/react-native-gallery-toolkit · packages/common/src/common.ts:99
export function runOnce(fn: Function) {
const ref = useRef<null | true>(null);
if (!ref.current) {
fn();
ref.current = true;
}
}
export function assertWorkletCreator(packageName: string) {
return function assert(fn: (...args: any[]) => any) {
// @ts-expect-error
if (!fn.__worklet)
throw new Error(
`${packageName}: ${fn.name} change should be a worklet. Did you forget to add "worklet" directive?`,
);
};
}