reblendjs
Version:
This is build using react way of handling dom but with web components
50 lines • 1.26 kB
JavaScript
import { isCallable } from '../../common/utils';
import { Reblend } from '../../internal/Reblend';
//@ReblendComponent
class TryCatchError extends Reblend {
static ELEMENT_NAME = "TryCatchError";
constructor() {
super();
}
async initState() {
//@ts-ignore
this && (
//@ts-ignore
this.renderingErrorHandler = e => {
//@ts-ignore
this.renderingError = e;
//if (!this.stateEffectRunning && this.attached) {
//Promise.resolve().then(() => {
//@ts-ignore
this?.onStateChange();
//})
//}
});
const view = () => {
const arr = [];
for (const child of this.props.children) {
if (isCallable(child)) {
//@ts-ignore
arr.push(child(this.renderingError));
} else {
arr.push(child);
}
}
//@ts-ignore
this.renderingError = null;
return arr;
};
this.state.view = view;
}
async initProps({
children = _error => Reblend.construct.bind(this)(Reblend, null, '')
}) {
this.props = {};
this.props.children = children;
}
async html() {
return Reblend.construct.bind(this)("div", null, this.state.view());
}
}
/* Transformed from function to class */
export { TryCatchError };