UNPKG

common-hook

Version:
21 lines (20 loc) 477 B
import { isFunction, isBrowser } from "common-screw"; export function getTargetElement(target, defaultElement) { if (!isBrowser()) { return undefined; } if (!target) { return defaultElement; } let targetElement; if (isFunction(target)) { targetElement = target(); } else if ("current" in target) { targetElement = target.current; } else { targetElement = target; } return targetElement; }