OnCancel event failure of Model components using antd in React

problem description

using the Model (pop-up window) component of antd in the React project, official document says: onCancel is a callback that clicks on the mask layer or the upper-right cross or cancel button, implying that if you need to turn off Modal in these actions, set the state that controls whether the Modal is visible to false in this event. In fact, I did the same.

the environmental background of the problems and what methods you have tried

I have checked to see if there is a spelling problem, which can rule out
. In addition, I also use the view layer method bind (this) in the constructor, and context has no problem.
about whether the method is called? Called, but the attempt to change the value of state in onCancel failed, so the Modal was not closed, why would it fail?

related codes

import { Modal } from "antd"

class CustomButton extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      popupVisible: true,
      wording: "123",
    }

    this.showCustomPopup = this.showCustomPopup.bind(this)
    this.handleCancel = this.handleCancel.bind(this)
  }

  showCustomPopup() {
    this.setState({ popupVisible: true })
  }

  handleCancel() {
    this.setState({
      popupVisible: false,
      wording: "666"
    })
    console.log(`visible in state: ${this.state.popupVisible}`)
  }

  render() {
    return (
      <div className="container" onClick={this.showCustomPopup}>
        <span>
          <Modal
            visible={this.state.popupVisible}
            onCancel={this.handleCancel}
          >
            {this.state.wording}
          </Modal>
        </span>
      </div>
    )
  }
}
Apr.03,2022

found the problem.
for React components bound with events, bubbles will be performed according to the tree structure of the component in React. For example, in the recent process of using antd, the structure is as follows:

...
constructor(props){
  this.state = {
    visible: false
  }
  this.showModal = this.showModal.bind(this)
  this.handleCancel = this.handleCancel.bind(this)
}

showModal() {
  this.setState({visible: true})
}

handleCancel() {
  this.setState({visible: false})
}

render() {
  return (
    <div className='container' onClick={this.showModal}>
      <Model visible={this.state.visible} onCancel={this.handleCancel} />
    </div>
  )
}
...

after clicking the container Modal pop-up, clicking the cancel button / mask / close icon of Modal will fail, resulting in the inability to close Modal. As an internal element, the onClick event of the Modal component bubbles up to the container div, so visible becomes true again, and you need to stop bubbling manually!

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