Design problems of React components

Why does the React Modal component click the close Modal button at design time not to deal with the close logic directly within the component, but to tell the external component to close the Modal, through the event, while the Vue element-ui can handle and close the Dialog logic within the component on its own

https://design.alipay.com/dev.
http://element.eleme.io/-sharp/zh-.


import { Modal, Button } from 'antd';

const confirm = Modal.confirm;

function showConfirm() {
  confirm({
    title: 'Do you want to delete these items?',
    content: 'When clicked the OK button, this dialog will be closed after 1 second',
    onOk() {
      return new Promise((resolve, reject) => {
        setTimeout(Math.random() > 0.5 ? resolve : reject, 1000);
      }).catch(() => console.log('Oops errors!'));
    },
    onCancel() {},
  });
}

ReactDOM.render(
  <Button onClick={showConfirm}>
    Confirm
  </Button>,
  mountNode);

take a good look. All right,
there are some

.

first of all, the effect of the two must be the same. There is no doubt that
react itself was designed to think that the state of the component is determined by the properties of the component
then the modal in antd-design is the same. When designing, we wanted this component to be controlled by some externally given attribute, so it was naturally designed

.
Menu