/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/hooks/src/createCurrentHook.ts
24 строки
650 B
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import type { Hooks, StoreKey } from './types'; /** * 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: Hooks, storeKey: StoreKey ): () => string | null { return function currentHook() { const hooksStore = hooks[ storeKey ]; const currentArray = Array.from( hooksStore.__current ); return currentArray.at( -1 )?.name ?? null; }; } export default createCurrentHook;