UNPKG

usehook

Version:
29 lines (23 loc) 796 B
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } // pass in the hook you wanna use and its value, receive a renderprop with its' values! var UseHook = function (_ref) { var _ref$hook = _ref.hook, useHook = _ref$hook[0], hookValues = _ref$hook.slice(1), children = _ref.children, props = _objectWithoutPropertiesLoose(_ref, ["hook", "children"]); var hooked = useHook.apply(void 0, hookValues); return children.apply(void 0, [hooked].concat(props)); }; export default UseHook;