The problem of data call in react

when the getComment addComment page of the two interfaces is loaded, call getComment to put the return value of getComment into state, and then render it. At this time, I call addComment to change the return value of getComment. Do you want to call the getComment API again to update the original value of getComment in state? if you don"t need the value in state, how to update the latest value after calling addComment



state = {
    data: '',
}

getComment = () => {
    
    .....
    
    const data = 
    this.setState({
        data,
    })
}

addComment = () => {

    ....

    this.getComment()
}

add comments:
1, submit to the backend
2, and the front end only needs to go to push to enter the existing comments in the state, and the page will be re-rendered.

there is no need to render by re-going to getcomment. When submitting, ask the backend to return the set of comments submitted to you in the same format as the one returned by getcomment. Then push enters the state.

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