Include catch in wrappers
This commit is contained in:
parent
0d57129de7
commit
7d71d4f450
|
@ -66,10 +66,11 @@ const ReactUtils = {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.element = element;
|
this.element = element;
|
||||||
|
this.state = {hasError: false};
|
||||||
}
|
}
|
||||||
|
componentDidCatch() {this.setState({hasError: true});}
|
||||||
componentDidMount() {this.refs.element.appendChild(this.element);}
|
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"});}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -293,6 +293,11 @@ export default class Modals {
|
||||||
super(props);
|
super(props);
|
||||||
this.elementRef = React.createRef();
|
this.elementRef = React.createRef();
|
||||||
this.element = panel;
|
this.element = panel;
|
||||||
|
this.state = {hasError: false};
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidCatch() {
|
||||||
|
this.setState({hasError: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -300,6 +305,7 @@ export default class Modals {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
if (this.state.hasError) return null;
|
||||||
const props = {
|
const props = {
|
||||||
className: "bd-addon-settings-wrap",
|
className: "bd-addon-settings-wrap",
|
||||||
ref: this.elementRef
|
ref: this.elementRef
|
||||||
|
|
Loading…
Reference in New Issue