diff --git a/renderer/src/modules/api/reactutils.js b/renderer/src/modules/api/reactutils.js index b9edfc43..c5b3e28e 100644 --- a/renderer/src/modules/api/reactutils.js +++ b/renderer/src/modules/api/reactutils.js @@ -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"});} }; } diff --git a/renderer/src/ui/modals.js b/renderer/src/ui/modals.js index d03e5a76..da72056d 100644 --- a/renderer/src/ui/modals.js +++ b/renderer/src/ui/modals.js @@ -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