UNPKG

368 BJavaScriptView Raw
1import { useMemo } from 'react';
2export function useOptionalFactory(arg, deps) {
3 const memoDeps = [
4 ...deps || []
5 ];
6 if (deps == null && typeof arg !== 'function') {
7 memoDeps.push(arg);
8 }
9 return useMemo(()=>{
10 return typeof arg === 'function' ? arg() : arg;
11 }, memoDeps);
12}
13
14//# sourceMappingURL=useOptionalFactory.js.map
\No newline at end of file