| 72 | Component_: React.ComponentType<P> |
| 73 | ): React.ComponentClass<P, unknown> { |
| 74 | return class DecoratedComponent extends React.Component<P> { |
| 75 | constructor(props: P, context: any) { |
| 76 | super(props, context); |
| 77 | } |
| 78 | onRef = (decorated_: any) => { |
| 79 | if (this.props.onDecorated) { |
| 80 | try { |
| 81 | // eslint-disable-next-line @typescript-eslint/no-unsafe-call |
| 82 | this.props.onDecorated(decorated_); |
| 83 | } catch (e) { |
| 84 | notify('Plugin error', `Error occurred. Check Developer Tools for details`, {error: e}); |
| 85 | } |
| 86 | } |
| 87 | }; |
| 88 | render() { |
| 89 | return React.createElement(Component_, Object.assign({}, this.props, {ref: this.onRef})); |
| 90 | } |
| 91 | }; |
| 92 | } |
| 93 | |
| 94 | function getDecorated<P extends Record<string, any>>( |