Include catch in wrappers

This commit is contained in:
Zack Rauen 2023-03-08 20:07:10 -05:00
parent 0d57129de7
commit 7d71d4f450
2 changed files with 9 additions and 2 deletions

View File

@ -66,10 +66,11 @@ const ReactUtils = {
constructor(props) {
super(props);
this.element = element;
this.state = {hasError: false};
}
componentDidCatch() {this.setState({hasError: true});}
componentDidMount() {this.refs.element.appendChild(this.element);}
render() {return DiscordModules.React.createElement("div", {className: "react-wrapper", ref: "element"});}
render() {return this.state.hasError ? null : DiscordModules.React.createElement("div", {className: "react-wrapper", ref: "element"});}
};
}

View File

@ -293,6 +293,11 @@ export default class Modals {
super(props);
this.elementRef = React.createRef();
this.element = panel;
this.state = {hasError: false};
}
componentDidCatch() {
this.setState({hasError: true});
}
componentDidMount() {
@ -300,6 +305,7 @@ export default class Modals {
}
render() {
if (this.state.hasError) return null;
const props = {
className: "bd-addon-settings-wrap",
ref: this.elementRef