File tree Expand file tree Collapse file tree 4 files changed +37
-11
lines changed Expand file tree Collapse file tree 4 files changed +37
-11
lines changed File renamed without changes.
Original file line number Diff line number Diff line change 33 */
44import { Component } from '@wordpress/element' ;
55
6- export class PluginErrorBoundary extends Component {
7- /**
8- * @param {Object } props
9- */
10- constructor ( props ) {
6+ /**
7+ * Internal dependencies
8+ */
9+ import type {
10+ PluginErrorBoundaryProps as Props ,
11+ PluginErrorBoundaryState as State ,
12+ } from '../../types' ;
13+
14+ export class PluginErrorBoundary extends Component < Props , State > {
15+ constructor ( props : Props ) {
1116 super ( props ) ;
1217 this . state = {
1318 hasError : false ,
1419 } ;
1520 }
1621
17- static getDerivedStateFromError ( ) {
22+ static getDerivedStateFromError ( ) : State {
1823 return { hasError : true } ;
1924 }
2025
21- /**
22- * @param {Error } error Error object passed by React.
23- */
24- componentDidCatch ( error ) {
26+ componentDidCatch ( error : Error ) : void {
2527 const { name, onError } = this . props ;
2628 if ( onError ) {
2729 onError ( name , error ) ;
2830 }
2931 }
3032
31- render ( ) {
33+ render ( ) : React . ReactNode {
3234 if ( ! this . state . hasError ) {
3335 return this . props . children ;
3436 }
File renamed without changes.
Original file line number Diff line number Diff line change 1+ /**
2+ * Props for the PluginErrorBoundary component.
3+ */
4+ export interface PluginErrorBoundaryProps {
5+ /**
6+ * The name of the plugin that may encounter an error.
7+ */
8+ name : string ;
9+ /**
10+ * The child components to render.
11+ */
12+ children : React . ReactNode ;
13+ /**
14+ * Callback function called when an error occurs.
15+ */
16+ onError ?: ( name : string , error : Error ) => void ;
17+ }
18+
19+ /**
20+ * State for the PluginErrorBoundary component.
21+ */
22+ export interface PluginErrorBoundaryState {
23+ hasError : boolean ;
24+ }
You can’t perform that action at this time.
0 commit comments