/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/plugins/src/components/plugin-error-boundary/index.tsx
33 строки
653 B
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import { Component } from '@wordpress/element'; import type { PluginErrorBoundaryProps as Props, PluginErrorBoundaryState as State, } from '../../types'; export class PluginErrorBoundary extends Component< Props, State > { constructor( props: Props ) { super( props ); this.state = { hasError: false, }; } static getDerivedStateFromError(): State { return { hasError: true }; } componentDidCatch( error: Error ): void { const { name, onError } = this.props; if ( onError ) { onError( name, error ); } } render(): React.ReactNode { if ( ! this.state.hasError ) { return this.props.children; } return null; } }