深入學習 React 合成事件

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"italic"}],"text":"以下分析基於React, ReactDOM 16.13.1版本"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"提出問題"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我們借鑑一個比較典型的案例開始來分析"},{"type":"codeinline","content":[{"type":"text","text":"React"}]},{"type":"text","text":"事件"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"javascript"},"content":[{"type":"text","text":"export default class Dialog extends React.PureComponent {\n  state = {\n    showBox: false\n  };\n  componentDidMount() {\n    document.addEventListener(\"click\", this.handleClickBody, false);\n  }\n  handleClickBody = () => {\n    this.setState({\n      showBox: false\n    });\n  };\n  handleClickButton = (e) => {\n    e.nativeEvent.stopPropagation();\n    this.setState({\n      showBox: true\n    });\n  };\n  render() {\n    return (\n      
\n