Merge branch 'react-17-deprecated' into 'develop'

Bundle: componentWillReceiveProps --> componentDidUpdate, React 17 compatibility

See merge request soapbox-pub/soapbox-fe!871
This commit is contained in:
Alex Gleason 2021-11-15 20:36:09 +00:00
commit 511f1de436

View file

@ -26,7 +26,7 @@ class Bundle extends React.PureComponent {
onFetchFail: noop, onFetchFail: noop,
} }
static cache = new Map static cache = new Map()
state = { state = {
mod: undefined, mod: undefined,
@ -34,12 +34,12 @@ class Bundle extends React.PureComponent {
} }
componentDidMount() { componentDidMount() {
this.load(this.props); this.load();
} }
componentWillReceiveProps(nextProps) { componentDidUpdate(prevProps) {
if (nextProps.fetchComponent !== this.props.fetchComponent) { if (this.props.fetchComponent !== prevProps.fetchComponent) {
this.load(nextProps); this.load();
} }
} }
@ -49,8 +49,8 @@ class Bundle extends React.PureComponent {
} }
} }
load = (props) => { load = () => {
const { fetchComponent, onFetch, onFetchSuccess, onFetchFail, renderDelay } = props || this.props; const { fetchComponent, onFetch, onFetchSuccess, onFetchFail, renderDelay } = this.props;
const cachedMod = Bundle.cache.get(fetchComponent); const cachedMod = Bundle.cache.get(fetchComponent);
if (fetchComponent === undefined) { if (fetchComponent === undefined) {