On the problem of setstate in react

when I use react and ant desgin pro, I want to click a button to open the drawer on the right to get the data, but I can"t get it immediately. I need to repeat it two or three times. How to solve

related codes

showDrawer = (record, operation = "") => {
    const { dispatch, codeCheckInfo } = this.props;
    const { checkInfo } = this.state;
    
    this.setState({
      targetReposity: record,
      drawerVisible: true,
      operation: operation,
      commitsListLoading: true,
    })

    if( operation === "view") {
      dispatch({
        type: "reposity/fetchReposityCommits",
        payload: {
          project_id: record.id,
          page_size: 10,
        }
      });
    }else if( operation === "check") {
      dispatch({
        type: "codeCheck/fetchCodeCheckInfo",
        payload: {
          project_id: record.id,
        }
      });
      this.setState({
        checkInfo: codeCheckInfo,
      })
      console.log(checkInfo)
      const columnsCheck = [
      {
        title: "",
        dataIndex: "name",
        key: "name",
        render: (text, record) => <span>{record.name || "-"}</span>,
        sorter: (a, b) => a.name.length - b.name.length,
      },
      {
        title: "",
        dataIndex: "errors",
        key: "errors",
        render: (text, record) => <span>{record.errors || "-"}</span>,
      },
      {
        title: " ",
        dataIndex: "-",
        render: (text, record, index) => <a href="-sharp" onClick={() => this.showDetail(record)}></a>
      }
    ]
    
     {operation === "check" && authority.includes("code") && (
            <Table className={styles.check_table1}
              columns={columnsCheck}
              rowkey={record => record.name}
              dataSource={newData.length ? newData : []}
              // loading={commitsListLoading}
            /> 
          )}

what result do you expect? What is the error message actually seen?

the checkinfo I need is not updated the first time, but will not be updated until the second click!

Nov.10,2021

this is setState is asynchronous
`this.setState ({

)
    checkInfo: codeCheckInfo,
  }, ()=>{
   console.log(checkInfo) //
  })

`


I have extracted this part again into a new component, so that it does not affect

Menu