35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
// Metro module 1751 (f1752).
|
|
import { useEffect, useRef } from "react";
|
|
import { makeShareable } from "./freezeObjectInDev";
|
|
import { isWorkletFunction } from "./Module1631";
|
|
import { ReanimatedError } from "./Module1617";
|
|
import { buildDependencies, areDependenciesEqual } from "./isAnimated";
|
|
import { isWeb, isJest } from "./Module1609";
|
|
export function useHandler(a0, a1) {
|
|
const ref = useRef(null);
|
|
if (ref.current === null) {
|
|
ref.current = {
|
|
context: makeShareable({}),
|
|
savedDependencies: []
|
|
};
|
|
}
|
|
useEffect(() => () => {
|
|
ref.current = null;
|
|
}, []);
|
|
const current = ref.current;
|
|
const { context, savedDependencies } = current;
|
|
for (const key in a0) {
|
|
if (!isWorkletFunction(a0[key])) {
|
|
throw new ReanimatedError("Passed a function that is not a worklet. Please provide a worklet function.");
|
|
}
|
|
}
|
|
const savedDependencies2 = buildDependencies(a1, a0);
|
|
const doDependenciesDiffer = !areDependenciesEqual(savedDependencies2, savedDependencies);
|
|
ref.current.savedDependencies = savedDependencies2;
|
|
return {
|
|
context,
|
|
doDependenciesDiffer,
|
|
useWeb: isWeb() || isJest()
|
|
};
|
|
}
|