React requests correspond one to one, so state maintenance is tedious.

react corresponds to two asynchronous requests in the same component, which indicates that state maintenance is cumbersome

here is my code

componentWillReceiveProps(nextProps){
    const {result1, result2} = nextProps;
    if(result1 === "success"){
        console.log(1)
    }
    if(result2 === "success"){
        console.log(2)
    }
}

when request 2 succeeds, the status of request 1 is still success and they will execute it all, but I just need them to execute it once each. My own solution is to compare the props value with the current value, but the tedious result is as follows:

componentWillReceiveProps(nextProps){
    const {result1, result2} = nextProps;
    const {result1: originalValue1, result2: originalValue2} = this.props;
    if(result1 === "success" && result1 !== originalValue1 ){
        console.log(1)
    }
    if(result2 === "success" && result2 !== originalValue2){
        console.log(2)
    }
}

-another type of sharp-sharp-sharp is the reset result value after finishing, but it will be re-render. I hope you can give better suggestions, thank you!

Apr.20,2022
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-1b39931-2c1bf.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-1b39931-2c1bf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?