{"id":412,"date":"2017-02-17T12:02:52","date_gmt":"2017-02-17T04:02:52","guid":{"rendered":"http:\/\/www.qdabc.cn\/?p=412"},"modified":"2017-02-17T17:27:22","modified_gmt":"2017-02-17T09:27:22","slug":"%e5%85%b3%e4%ba%8ereact%e7%bb%84%e4%bb%b6%e7%9a%84%e7%94%9f%e5%91%bd%e5%91%a8%e6%9c%9f%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"http:\/\/www.qdabc.cn\/?p=412","title":{"rendered":"\u5173\u4e8eReact\u7ec4\u4ef6\u7684\u751f\u547d\u5468\u671f\u4ecb\u7ecd"},"content":{"rendered":"<p>\u4e00\u4e2aReact\u7ec4\u4ef6\u88ab\u6e32\u67d3\u7684\u8fc7\u7a0b\u6709\u4e09\u4e2a\u9636\u6bb5\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u5c31\u53eb\u505a\u7ec4\u4ef6\u7684\u751f\u547d\u5468\u671f\u3002\u6bcf\u4e2aReact\u7ec4\u4ef6\u90fd\u4f1a\u7ecf\u5386\u8fd9\u4e2a\u8fc7\u7a0b\u3002\u4e3a\u4e86\u4f7f\u8fd9\u4e2a\u8fc7\u7a0b\u53ef\u64cd\u63a7\uff0cReact\u63d0\u4f9b\u4e86\u4e00\u4e9b\u65b9\u6cd5\uff0c\u5728\u7ec4\u4ef6\u751f\u547d\u5468\u671f\u8fc7\u7a0b\u4e2d\uff0c\u901a\u8fc7\u8fd9\u4e9b\u65b9\u6cd5\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\u67d0\u4e2a\u9636\u6bb5\u53d1\u751f\u7684\u901a\u77e5\u3002\u8fd9\u4e9b\u65b9\u6cd5\u5c31\u53eb\u4f5c\u7ec4\u4ef6\u7684\u751f\u547d\u5468\u671f\u65b9\u6cd5\uff0c\u5b83\u4eec\u6309\u7279\u5b9a\u987a\u5e8f\u88ab\u8c03\u7528\u3002<\/p>\n<p>\u6240\u6709React\u7ec4\u4ef6\u7684\u751f\u547d\u5468\u671f\u65b9\u6cd5\u53ef\u4ee5\u5206\u4e3a\u4e0b\u9762\u4e09\u4e2a\u9636\u6bb5\u3002<\/p>\n<ul class=\" list-paddingleft-2\">\n<li>\u6302\u8f7d\uff08Mounting\uff09\uff1a\u8fd9\u4e2a\u9636\u6bb5\u53d1\u751f\u5728\u7ec4\u4ef6\u88ab\u63d2\u5165DOM\u65f6\u3002<\/li>\n<li>\u66f4\u65b0\uff08Updating\uff09\uff1a\u8fd9\u4e2a\u9636\u6bb5\u53d1\u751f\u5728\u7ec4\u4ef6\u88ab\u91cd\u65b0\u6e32\u67d3\u6210\u865a\u62dfDOM\u5e76\u51b3\u5b9a\u5b9e\u9645DOM\u662f\u5426\u9700\u8981\u66f4\u65b0\u65f6\u3002<\/li>\n<li>\u5378\u8f7d\uff08Unmounting\uff09\uff1a\u8fd9\u4e2a\u9636\u6bb5\u53d1\u751f\u5728\u7ec4\u4ef6\u4eceDOM\u4e2d\u88ab\u5220\u9664\u65f6\u3002<\/li>\n<\/ul>\n<h2 id=\"\u6302\u8f7d\"><img class=\"anchorclass\" \/>\u6302\u8f7d<\/h2>\n<p>\u4e0b\u9762\u7684\u65b9\u6cd5\u6309\u5e8f\u6267\u884c\u3002<\/p>\n<h3 id=\"getdefaultprops\"><img class=\"anchorclass\" \/>getDefaultProps()<\/h3>\n<p>\u6b64\u65b9\u6cd5\u53ef\u4ee5\u7ed9\u7ec4\u4ef6\u8bbe\u7f6e\u9ed8\u8ba4\u7684\u5c5e\u6027\u3002\u5728render\u6e32\u67d3\u7684\u7ec4\u4ef6\u4e2d\u53ef\u4ee5\u901a\u8fc7this.props.someprop\u8c03\u7528\u3002<\/p>\n<pre class=\"brush:js;toolbar:false\">getDefaultProps: function() {\r\n  console.log('getDefaultProps');\r\n  return {\r\n    text : 'hello'\r\n  } \r\n},\r\nrender: function () {\r\n  return (\r\n    &lt;h2&gt;{this.props.text}&lt;\/h2&gt;\r\n  );\r\n}<\/pre>\n<h3 id=\"getinitialstate\"><img class=\"anchorclass\" \/>getInitialState()<\/h3>\n<p>getInitialState()\u65b9\u6cd5\u662f\u7b2c\u4e00\u4e2a\u88ab\u8c03\u7528\u7684\uff0c\u5b83\u4f1a\u5728React\u5c06\u7ec4\u4ef6\u63d2\u5165DOM\u4e4b\u524d\u88ab\u8c03\u7528\u3002\u5982\u679c\u60f3\u8ba9\u7ec4\u4ef6\u6709\u4e00\u4e2a\u72b6\u6001\uff08state\uff09\uff0c\u90a3\u4e48\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u65b9\u6cd5\u8fd4\u56de\u521d\u59cb\u7684\u7ec4\u4ef6state\u3002<\/p>\n<pre class=\"brush:js;toolbar:false\">getInitialState: function() {\r\n  console.log('getInitialState');\r\n  return {\r\n    state1: 'state1',\r\n    state2: 'state2'\r\n  }\r\n}<\/pre>\n<h3 id=\"componentwillmount\"><img class=\"anchorclass\" \/>componentWillMount()<\/h3>\n<p>componentWillMount()\u65b9\u6cd5\u662f\u7b2c\u4e8c\u4e2a\u88ab\u8c03\u7528\u7684\uff0c\u5b83\u4f1a\u5728React\u5c06\u7ec4\u4ef6\u5373\u5c06\u63d2\u5165DOM\u65f6\u88ab\u8c03\u7528\u3002<\/p>\n<pre class=\"brush:js;toolbar:false\">componentWillMount: function() {\r\n  console.log('componentWillMount');\r\n  this.setState({\r\n    state1: 'state11',\r\n    state1: 'state22'\r\n  })\r\n  window.a = 1;\r\n}<\/pre>\n<p>\u8c03\u7528this.setState()\u65b9\u6cd5\u4f1a\u89e6\u53d1\u7ec4\u4ef6\u7684render()\u65b9\u6cd5\uff0c\u6240\u4ee5\u770b\u8d77\u6765\u50cf\u662f\u5728\u7ec4\u4ef6\u6302\u8f7d\u9636\u6bb5render()\u65b9\u6cd5\u88ab\u8c03\u7528\u4e86\u4e24\u6b21\u3002\u7136\u800c\u5728\u8fd9\u91cc\uff0cReact\u77e5\u9053\u8fd8\u6ca1\u6709\u5f00\u59cb\u6e32\u67d3\uff0c\u6240\u4ee5\u5b83\u5c06\u4ec5\u4ec5\u8c03\u7528render()\u65b9\u6cd5\u4e00\u6b21\u3002<\/p>\n<h3 id=\"render\"><img class=\"anchorclass\" \/>render()<\/h3>\n<p>\u6700\u57fa\u672c\u7684\uff0cReact\u7ec4\u4ef6\u9700\u8981\u4e00\u4e2arender()\u65b9\u6cd5\uff0c\u56e0\u6b64\u5b83\u81f3\u5c11\u4f1a\u8fd4\u56denull\u6216\u8005false\u3002render()\u8d1f\u8d23\u544a\u8bc9React\u600e\u6837\u6e32\u67d3\u8fd9\u4e2aReact\u7ec4\u4ef6\u3002\u5b83\u53ef\u4ee5\u8fd4\u56denull\uff0c\u8868\u793a\u4e0d\u6e32\u67d3\u4efb\u4f55\u5185\u5bb9\u3002\u5b83\u4e5f\u53ef\u4ee5\u8fd4\u56de\u4e00\u4e2a\u7ec4\u4ef6\u3002<br \/>\n\u4f7f\u7528React API\u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5c06\u6570\u636e\u4f20\u9012\u7ed9render()\u51fd\u6570\uff1a<\/p>\n<ul class=\" list-paddingleft-2\">\n<li>this.props<\/li>\n<li>this.state<\/li>\n<\/ul>\n<p>this.props\u5b58\u50a8\u7684\u662f\u4ece\u7236\u7ea7\u4f20\u8fc7\u6765\u7684\u53ea\u8bfb\u6570\u636e\u3002\u5b83\u5c5e\u4e8e\u7236\u7ea7\uff0c\u5e76\u4e14\u4e0d\u80fd\u88ab\u5b83\u7684\u5b50\u5143\u7d20\u6539\u53d8\u3002\u8fd9\u4e2a\u6570\u636e\u5e94\u5f53\u8ba4\u4e3a\u662f\u4e0d\u53ef\u6539\u53d8\u7684\u3002<br \/>\nthis.state\u5b58\u50a8\u7684\u6570\u636e\u662f\u7ec4\u4ef6\u79c1\u6709\u7684\u3002\u5b83\u80fd\u88ab\u7ec4\u4ef6\u4fee\u6539\u3002\u5f53state\u66f4\u65b0\u540e\u7ec4\u4ef6\u4f1a\u81ea\u52a8\u91cd\u65b0\u6e32\u67d3\uff08\u4e00\u822c\uff09\u3002<\/p>\n<h3 id=\"componentdidmount\"><img class=\"anchorclass\" \/>componentDidMount()<\/h3>\n<p>componentDidMount()\u65b9\u6cd5\u662f\u7b2c\u4e09\u4e2a\u88ab\u8c03\u7528\u7684\u3002\u5b83\u5728React\u5c06\u7ec4\u4ef6\u63d2\u5165\u5230DOM\u4e4b\u540e\u7acb\u5373\u88ab\u8c03\u7528\u3002\u66f4\u65b0\u540e\u7684DOM\u73b0\u5728\u53ef\u4ee5\u88ab\u8bbf\u95ee\uff0c<strong>\u8fd9\u610f\u5473\u7740\u8fd9\u4e2a\u65b9\u6cd5\u662f\u521d\u59cb\u5316\u5176\u4ed6\u9700\u8981\u8bbf\u95ee\u8fd9\u4e9bDOM\u7684JavaScript\u5e93\u7684\u6700\u4f73\u5730\u65b9\u3002<\/strong><\/p>\n<pre class=\"brush:js;toolbar:false\">componentDidMount: function() {\r\n  console.log('componentDidMount');\r\n  \/\/ \u83b7\u53d6dom\u8282\u70b9\r\n  var componentDOMNode = ReactDOM.findDOMNode(this);\r\n}<\/pre>\n<h2 id=\"\u66f4\u65b0\"><img class=\"anchorclass\" \/>\u66f4\u65b0<\/h2>\n<p>\u5728\u6b64\u9636\u6bb5\uff0cReact\u7ec4\u4ef6\u5df2\u7ecf\u88ab\u63d2\u5165\u5230DOM\u4e2d\u3002\u8fd9\u4e2aDOM\u4ee3\u8868\u7ec4\u4ef6\u7684\u5f53\u524d\u72b6\u6001\uff0c\u5e76\u4e14\u5f53\u72b6\u6001\u6539\u53d8\uff0cReact\u9700\u8981\u8bc4\u4f30\u4e00\u4e2a\u65b0\u7684\u72b6\u6001\u5c06\u5982\u4f55\u6539\u53d8\u5148\u524d\u6e32\u67d3\u7684DOM\u3002<\/p>\n<p>React\u7ec4\u4ef6\u67095\u4e2a\u5c5e\u4e8e\u7ec4\u4ef6\u66f4\u65b0\u9636\u6bb5\u7684\u58f0\u660e\u5468\u671f\u65b9\u6cd5\uff1a<\/p>\n<ul class=\" list-paddingleft-2\">\n<li>componentWillReceiveProps()<\/li>\n<li>shouldComponentUpdate()<\/li>\n<li>componentWillUpdate()<\/li>\n<li>render()<\/li>\n<li>componentDidUpdate<\/li>\n<\/ul>\n<p>render()\u65b9\u6cd5\u5df2\u7ecf\u4ecb\u7ecd\u8fc7\u3002<\/p>\n<h3 id=\"componentwillreceiveprops\"><img class=\"anchorclass\" \/>componentWillReceiveProps<\/h3>\n<p>\u8fd9\u4e2a\u65b9\u6cd5\u5728\u7ec4\u4ef6\u58f0\u660e\u5468\u671f\u66f4\u65b0\u9636\u6bb5\u88ab\u7b2c\u4e00\u4e2a\u8c03\u7528\uff0c\u5177\u4f53\u6765\u8bf4\uff0c\u5c31\u662f\u5f53\u7ec4\u4ef6\u4ece\u5b83\u7684\u7236\u7ec4\u4ef6\u63a5\u6536\u5230\u65b0\u5c5e\u6027\u65f6\u88ab\u8c03\u7528\u3002<\/p>\n<p>\u6b64\u65b9\u6cd5\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u4e2a\u673a\u4f1a\uff0c\u8ba9\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528this.props\u5bf9\u8c61\u548cnextProps\u5bf9\u8c61\u6765\u6bd4\u8f83\u5f53\u524d\u7ec4\u4ef6\u548c\u4e0b\u4e00\u4e2a\u7ec4\u4ef6\u7684\u5c5e\u6027\u3002<strong>\u6839\u636e\u6bd4\u8f83\u7ed3\u679c\uff0c\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528this.setState()\u51fd\u6570\u6765\u66f4\u65b0\u7ec4\u4ef6\u7684state\uff0c\u5728\u8fd9\u79cd\u573a\u666f\u4e0b\u5c06\u4e0d\u4f1a\u89e6\u53d1\u989d\u5916\u7684\u6e32\u67d3\u3002React\u505a\u4e86\u5185\u90e8\u4f18\u5316\uff0c\u4f1a\u628a\u72b6\u6001\u66f4\u65b0\u64cd\u4f5c\u653e\u5728\u4e00\u8d77\u6279\u91cf\u6267\u884c\u3002<\/strong><\/p>\n<pre class=\"brush:js;toolbar:false\">componentWillReceiveProps: function(nextProps) {\r\n  console.log('componentWillReceiveProps');\r\n\r\n  var current = this.props.parentComponentProp;\r\n  var next = nextProps.parentComponentProps;\r\n\r\n  if( Object.is(current, next) ) {\r\n    this.setState({\r\n      state1: 'state111',\r\n      state2: 'state222'\r\n    }) \r\n  }\r\n}<\/pre>\n<h3 id=\"shouldcomponentupdate\"><img class=\"anchorclass\" \/>shouldComponentUpdate()<\/h3>\n<p>\u901a\u8fc7\u8fd9\u4e2a\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u51b3\u5b9a\u7ec4\u4ef6\u7684\u4e0b\u4e00\u4e2a\u72b6\u6001\u662f\u5426\u89e6\u53d1\u7ec4\u4ef6\u7684\u91cd\u65b0\u6e32\u67d3\u3002\u8fd9\u4e2a\u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u5e03\u5c14\u503c\uff0c\u9ed8\u8ba4\u503c\u662ftrue\u3002\u4f46\u662f\u4e5f\u53ef\u4ee5\u4f7f\u5b83\u8fd4\u56defalse\uff0c\u6b64\u65f6\u4e0b\u9762\u7684\u7ec4\u4ef6\u65b9\u6cd5\u90fd\u4e0d\u4f1a\u88ab\u8c03\u7528\u3002<\/p>\n<ul class=\" list-paddingleft-2\">\n<li>componentWillUpdate()<\/li>\n<li>render()<\/li>\n<li>componentDidUpdate()<\/li>\n<\/ul>\n<p>\u5982\u679c\u8df3\u8fc7\u5bf9\u7ec4\u4ef6\u7684render()\u65b9\u6cd5\u7684\u8c03\u7528\uff0c\u5c31\u4f1a\u963b\u6b62\u5bf9\u8be5\u7ec4\u4ef6\u7684\u91cd\u65b0\u6e32\u67d3\uff0c\u8fd9\u5c06\u63d0\u9ad8\u5e94\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\uff0c\u56e0\u4e3a\u6ca1\u6709\u989d\u5916\u7684DOM\u6539\u53d8\u3002<br \/>\nshouldComponentUpdate()\u65b9\u6cd5\u5728\u7ec4\u4ef6\u58f0\u660e\u5468\u671f\u7684\u66f4\u65b0\u9636\u6bb5\u88ab\u7b2c\u4e8c\u4e2a\u8c03\u7528\u3002<\/p>\n<pre class=\"brush:js;toolbar:false\">shouldComponentUpdate: function (nextProps, nextState) {\r\n  console.log('shouldComponentUpdate');\r\n\r\n  return (!!nextProps.parentComponentProps);\r\n}<\/pre>\n<h3 id=\"componentwillupdate\"><img class=\"anchorclass\" \/>componentWillUpdate()<\/h3>\n<p>componentWillUpdate()\u65b9\u6cd5\u5728React\u5373\u5c06\u66f4\u65b0DOM\u4e4b\u524d\u88ab\u8c03\u7528\u3002\u5b83\u5f97\u5230\u4e00\u4e0b\u4e24\u4e2a\u53c2\u6570\uff1a<\/p>\n<ul class=\" list-paddingleft-2\">\n<li>nextProps\uff1a\u4e0b\u4e00\u4e2a\u5c5e\u6027\u5bf9\u8c61<\/li>\n<li>nextState\uff1a\u4e0b\u4e00\u4e2a\u72b6\u6001\u5bf9\u8c61<\/li>\n<\/ul>\n<p>\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e9b\u53c2\u6570\u6765\u51c6\u5907DOM\u66f4\u65b0\u3002<strong>\u4e0d\u8fc7\uff0c\u4f60\u4e0d\u80fd\u5728componentWillUpdate()\u65b9\u6cd5\u4e2d\u4f7f\u7528this.setState()\u3002\u5982\u679c\u4f60\u60f3\u66f4\u65b0\u7ec4\u4ef6\u7684\u72b6\u6001\u4ee5\u54cd\u5e94\u5176\u5c5e\u6027\u4fee\u6539\uff0c\u90a3\u4e48\u8bf7\u5728componentWillReceiveProps()\u65b9\u6cd5\u4e2d\u505a\uff0cReact\u4f1a\u5728\u5c5e\u6027\u53d8\u5316\u65f6\u8c03\u7528\u5b83\u3002<\/strong><\/p>\n<pre class=\"brush:js;toolbar:false\">componentWillUpdate: function() {\r\n  console.log('componentWillUpdate');\r\n}<\/pre>\n<p>\u5728\u8c03\u7528componentWillUpdate()\u65b9\u6cd5\u4e4b\u540e\uff0cReact\u8c03\u7528render()\u65b9\u6cd5\u6765\u6267\u884cDOM\u66f4\u65b0\u3002\u7136\u540ecomponentDidUpdate()\u65b9\u6cd5\u88ab\u8c03\u7528\u3002<\/p>\n<h3 id=\"componentdidupdate\"><img class=\"anchorclass\" \/>componentDidUpdate()<\/h3>\n<p>componentDidUpdate()\u65b9\u6cd5\u5728React\u66f4\u65b0DOM\u4e4b\u540e\u4f1a\u88ab\u7acb\u5373\u8c03\u7528\u3002\u5b83\u5f97\u5230\u5982\u4e0b\u4e24\u4e2a\u53c2\u6570\uff1a<\/p>\n<ul class=\" list-paddingleft-2\">\n<li>prevProps\uff1a\u4e0a\u4e00\u4e2a\u5c5e\u6027\u5bf9\u8c61<\/li>\n<li>prevState\uff1a\u4e0a\u4e00\u4e2a\u72b6\u6001\u5bf9\u8c61<\/li>\n<\/ul>\n<p>\u6211\u4eec\u5c06\u4f7f\u7528\u8fd9\u4e2a\u65b9\u6cd5\u6765\u64cd\u4f5c\u66f4\u65b0\u540e\u7684DOM\u6216\u8005\u6267\u884c\u6e32\u67d3\u540e\u7684\u64cd\u4f5c\u3002\u5728componentDidUpdate()\u88ab\u8c03\u7528\u4e4b\u540e\uff0c\u66f4\u65b0\u9636\u6bb5\u7ed3\u675f\u3002<br \/>\n\u5f53\u7ec4\u4ef6\u7684\u72b6\u6001\u66f4\u65b0\u6216\u8005\u7236\u7ec4\u4ef6\u4f20\u6765\u4e00\u4e2a\u65b0\u7684\u5c5e\u6027\u65f6\uff0c\u4e00\u4e2a\u65b0\u9636\u6bb5\u53c8\u5f00\u59cb\u4e86\u3002\u6216\u8005\uff0c\u8c03\u7528forceUpdate()\u65b9\u6cd5\u4e5f\u4f1a\u89e6\u53d1\u4e00\u4e2a\u65b0\u7684\u66f4\u65b0\u9636\u6bb5\uff0c\u53ea\u662f\u5728\u89e6\u53d1\u66f4\u65b0\u7684\u7ec4\u4ef6\u4e0a\u4f1a\u8df3\u8fc7shouldComponentUpdate()\u65b9\u6cd5\u3002\u4e0d\u8fc7\uff0c\u5728\u6240\u6709\u5b50\u7ec4\u4ef6\u7684\u66f4\u65b0\u9636\u6bb5\uff0cshouldComponentUpdate()\u4ecd\u4f1a\u50cf\u5f80\u5e38\u4e00\u6837\u88ab\u8c03\u7528\u3002\u5b9e\u8df5\u4e2d\u5c3d\u91cf\u4e0d\u8981\u4f7f\u7528forceUpdate()\u65b9\u6cd5\uff0c\u8fd9\u6837\u80fd\u63d0\u9ad8\u7a0b\u5e8f\u7684\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n<h2 id=\"\u5378\u8f7d\"><img class=\"anchorclass\" \/>\u5378\u8f7d<\/h2>\n<p>\u5728\u8fd9\u4e2a\u9636\u6bb5React\u4ec5\u63d0\u4f9b\u4e00\u4e2a\u65b9\u6cd5\uff0c\u90a3\u5c31\u662fcomponentWillUnmount()\u3002\u5b83\u5728React\u5373\u5c06\u4eceDOM\u4e2d\u5220\u9664\u5e76\u9500\u6bc1\u7ec4\u4ef6\u4e4b\u524d\u8c03\u7528\u3002\u5bf9\u4e8e\u6e05\u7406\u7ec4\u4ef6\u5728\u5b89\u88c5\u6216\u66f4\u65b0\u9636\u6bb5\u521b\u5efa\u7684\u6240\u4ee5\u6570\u636e\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u662f\u5f88\u6709\u7528\u7684\u3002<\/p>\n<h3 id=\"componentwillunmount\"><img class=\"anchorclass\" \/>componentWillUnMount()<\/h3>\n<pre class=\"brush:js;toolbar:false\">componentWillUnmount: function() {\r\n  console.log('componentWillUnmount');\r\n  \/\/ \u6e05\u7406\u6570\u636e\r\n  delete window.a;\r\n}<\/pre>\n<p>\u5728\u6574\u5408React\u7ec4\u4ef6\u548c\u5176\u4ed6JavaScript API\u65f6\uff0c\u53ef\u4ee5\u5c06componentDidMount()\u548ccomponentWillUnmount()\u65b9\u6cd5\u60f3\u8c61\u6210\u4e00\u4e2a\u4e24\u90e8\u673a\u5236\uff1a<\/p>\n<ul class=\" list-paddingleft-2\">\n<li>\u5728componentDidMount()\u65b9\u6cd5\u4e2d\u521d\u59cb\u5316\u5b83\u4eec\u3002<\/li>\n<li>\u5728componentWillUnmount()\u65b9\u6cd5\u4e2d\u7ed3\u675f\u5b83\u4eec\u3002<\/li>\n<\/ul>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u4f7f\u9700\u8981\u64cd\u4f5cDOM\u7684\u7b2c\u4e09\u65b9JavaScript\u5e93\u4e0eReact\u6e32\u67d3\u7684DOM\u4fdd\u6301\u540c\u6b65\u3002<\/p>\n<h2 id=\"\u53c2\u8003\"><img class=\"anchorclass\" \/>\u53c2\u8003<\/h2>\n<blockquote><p>React\u7cbe\u9ad3(React.js Essentials)<\/p><\/blockquote>\n<p>\u200b<\/p>\n<p class=\"post-copyright\">\u6b22\u8fce\u5206\u4eab\u672c\u6587\uff0c\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u51fa\u5904\uff1a<a href=\"http:\/\/www.qdabc.cn\">\u524d\u7aefABC<\/a> &raquo; <a href=\"http:\/\/www.qdabc.cn\/?p=412\">\u5173\u4e8eReact\u7ec4\u4ef6\u7684\u751f\u547d\u5468\u671f\u4ecb\u7ecd<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u4e00\u4e2aReact\u7ec4\u4ef6\u88ab\u6e32\u67d3\u7684\u8fc7\u7a0b\u6709\u4e09\u4e2a\u9636\u6bb5\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u5c31\u53eb\u505a\u7ec4\u4ef6\u7684\u751f\u547d\u5468\u671f\u3002\u6bcf\u4e2aReact\u7ec4\u4ef6\u90fd\u4f1a\u7ecf\u5386\u8fd9\u4e2a\u8fc7\u7a0b\u3002\u4e3a\u4e86\u4f7f\u8fd9\u4e2a\u8fc7\u7a0b\u53ef\u64cd\u63a7\uff0cReact\u63d0\u4f9b\u4e86\u4e00\u4e9b\u65b9\u6cd5\uff0c\u5728\u7ec4\u4ef6\u751f\u547d\u5468\u671f\u8fc7\u7a0b\u4e2d\uff0c\u901a\u8fc7\u8fd9\u4e9b\u65b9\u6cd5\u6211\u4eec\u53ef\u4ee5\u5f97 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":325,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[39,93],"_links":{"self":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/412"}],"collection":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=412"}],"version-history":[{"count":1,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/412\/revisions"}],"predecessor-version":[{"id":413,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/412\/revisions\/413"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/media\/325"}],"wp:attachment":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=412"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}