/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/rich-text/src/input-event.js
31 строка
839 B
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import { useEffect, useContext } from '@wordpress/element'; import { useEvent } from '@wordpress/compose'; import { InputEventContext } from './contexts'; export function RichTextInputEvent( { inputType, onInput } ) { const callbacks = useContext( InputEventContext ); /* * Keep a stable reference to the latest `onInput` so the registered * callback can call it without re-running the registration effect on * every render. */ const stableOnInput = useEvent( onInput ); useEffect( () => { const inputCallbacks = callbacks.current; function callback( event ) { if ( event.inputType === inputType ) { stableOnInput(); event.preventDefault(); } } inputCallbacks.add( callback ); return () => { inputCallbacks.delete( callback ); }; }, [ inputType, callbacks, stableOnInput ] ); return null; }