Bundle: componentWillReceiveProps --> componentDidUpdate, React 17 compatibility

merge-requests/871/head
Alex Gleason 2021-11-15 14:34:33 -06:00
rodzic d4bf32c044
commit 926e92a742
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 7 dodań i 7 usunięć

Wyświetl plik

@ -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) {