From 926e92a7420bb3b0d09fa40114fffdd1cb28bc52 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 15 Nov 2021 14:34:33 -0600 Subject: [PATCH] Bundle: componentWillReceiveProps --> componentDidUpdate, React 17 compatibility --- app/soapbox/features/ui/components/bundle.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/soapbox/features/ui/components/bundle.js b/app/soapbox/features/ui/components/bundle.js index 7089597b6..b70ad342c 100644 --- a/app/soapbox/features/ui/components/bundle.js +++ b/app/soapbox/features/ui/components/bundle.js @@ -26,7 +26,7 @@ class Bundle extends React.PureComponent { onFetchFail: noop, } - static cache = new Map + static cache = new Map() state = { mod: undefined, @@ -34,12 +34,12 @@ class Bundle extends React.PureComponent { } componentDidMount() { - this.load(this.props); + this.load(); } - componentWillReceiveProps(nextProps) { - if (nextProps.fetchComponent !== this.props.fetchComponent) { - this.load(nextProps); + componentDidUpdate(prevProps) { + if (this.props.fetchComponent !== prevProps.fetchComponent) { + this.load(); } } @@ -49,8 +49,8 @@ class Bundle extends React.PureComponent { } } - load = (props) => { - const { fetchComponent, onFetch, onFetchSuccess, onFetchFail, renderDelay } = props || this.props; + load = () => { + const { fetchComponent, onFetch, onFetchSuccess, onFetchFail, renderDelay } = this.props; const cachedMod = Bundle.cache.get(fetchComponent); if (fetchComponent === undefined) {