diff --git a/src/components/structures/RoomSubList.js b/src/components/structures/RoomSubList.js index 1e3e15b4ec..4e8e51c3cc 100644 --- a/src/components/structures/RoomSubList.js +++ b/src/components/structures/RoomSubList.js @@ -37,6 +37,42 @@ import toRem from "../../utils/rem"; // turn this on for drop & drag console debugging galore const debug = false; +class RoomTileErrorBoundary extends React.PureComponent { + constructor(props) { + super(props); + + this.state = { + error: null, + }; + } + + static getDerivedStateFromError(error) { + // Side effects are not permitted here, so we only update the state so + // that the next render shows an error message. + return { error }; + } + + componentDidCatch(error, { componentStack }) { + // Browser consoles are better at formatting output when native errors are passed + // in their own `console.error` invocation. + console.error(error); + console.error( + "The above error occured while React was rendering the following components:", + componentStack, + ); + } + + render() { + if (this.state.error) { + return (