UNPKG

@wordpress/hooks

Version:
24 lines (23 loc) 764 B
/** * Internal dependencies */ /** * Returns a function which, when invoked, will return the name of the * currently running hook, or `null` if no hook of the given type is currently * running. * * @param hooks Hooks instance. * @param storeKey * * @return Function that returns the current hook name or null. */ function createCurrentHook(hooks, storeKey) { return function currentHook() { var _currentArray$at$name; const hooksStore = hooks[storeKey]; const currentArray = Array.from(hooksStore.__current); return (_currentArray$at$name = currentArray.at(-1)?.name) !== null && _currentArray$at$name !== void 0 ? _currentArray$at$name : null; }; } export default createCurrentHook; //# sourceMappingURL=createCurrentHook.js.map