From 974ddc28a38a164b43b2edc6deebdf3e0a6a7eed Mon Sep 17 00:00:00 2001 From: Claire Date: Sun, 28 Feb 2021 01:01:34 +0100 Subject: [PATCH] [Glitch] Fix WebUI crashing when SVG support is disabled Port 0635c8760dfdfeb3d763f1d1ae6cf5a208b29b6c to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/components/hashtag.js | 49 ++++++++++++++----- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/app/javascript/flavours/glitch/components/hashtag.js b/app/javascript/flavours/glitch/components/hashtag.js index 639d87a1e6..24c595ed7f 100644 --- a/app/javascript/flavours/glitch/components/hashtag.js +++ b/app/javascript/flavours/glitch/components/hashtag.js @@ -2,10 +2,35 @@ import React from 'react'; import { Sparklines, SparklinesCurve } from 'react-sparklines'; import { FormattedMessage } from 'react-intl'; +import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import Permalink from './permalink'; import ShortNumber from 'flavours/glitch/components/short_number'; +class SilentErrorBoundary extends React.Component { + + static propTypes = { + children: PropTypes.node, + }; + + state = { + error: false, + }; + + componentDidCatch () { + this.setState({ error: true }); + } + + render () { + if (this.state.error) { + return null; + } + + return this.props.children; + } + +} + /** * Used to render counter of how much people are talking about hashtag * @@ -51,17 +76,19 @@ const Hashtag = ({ hashtag }) => (
- day.get('uses')) - .toArray()} - > - - + + day.get('uses')) + .toArray()} + > + + +
);