How to solve the react memory leak?

clipboard.png

this._isMounted


clipboard.png

my requirement is to trigger the topImgs () method after the component is mounted, get the data list from the back end, and then assign the list to topImgsList.

Gods, please take a look. What went wrong?

Mar.11,2021

cause of the problem: before the asynchronous request is returned in topImgs , your component is already unmount . At this point, if you call setState again, you will report this error.

solution:

constructor() {
    super();
}
componentWillUnmount() {
    this.xhr && this.xhr.abort();
}
topImgs() => {
    this.xhr = React.axios();
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4c747-43e2d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4c747-43e2d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?