{"id":155385,"date":"2020-08-30T07:10:03","date_gmt":"2020-08-29T23:10:03","guid":{"rendered":"http:\/\/4563.org\/?p=155385"},"modified":"2020-08-30T07:10:03","modified_gmt":"2020-08-29T23:10:03","slug":"%e6%88%91%e5%8f%91%e7%8e%b0%e6%88%91%e4%b8%8d%e5%96%9c%e6%ac%a2%e7%94%a8-react-hooks","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=155385","title":{"rendered":"\u6211\u53d1\u73b0\u6211\u4e0d\u559c\u6b22\u7528 react-hooks"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6211\u53d1\u73b0\u6211\u4e0d\u559c\u6b22\u7528 react-hooks               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : cl903254852 <\/span>  <span><i><\/i> 5<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>react-hooks \u66f4\u9002\u5408\u5199\u903b\u8f91\u7b80\u5355\u7684\u5c0f\u7ec4\u4ef6\uff0c\u9047\u5230\u903b\u8f91\u590d\u6742\u7684\u7ec4\u4ef6\u76f8\u8f83 class component \u66f4\u96be\u7ef4\u62a4\uff08\u4e0d\u8981\u8ddf\u6211\u8bf4\u903b\u8f91\u62c6\u5206\u4ec0\u4e48\u7684\uff09\u3002<\/p>\n<p>\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6211\u7ef4\u62a4\u540c\u4e8b\u5199\u7684\u9875\u9762\uff0c\u5982\u679c\u662f class component \u6211\u4e00\u773c\u5c31\u80fd\u770b\u660e\u767d\u6574\u4e2a\u7ec4\u4ef6\u7ed3\u6784\uff0c\u4e00\u4e0b\u5c31\u80fd\u7784\u5230 componentDidMount<\/p>\n<p>\u8fd9\u662f\u6211\u4e2a\u4eba\u7684\u611f\u60f3<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>32<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3286963\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : whincwu142 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u7528\u7c7b\u4f3c react-use \u8fd9\u6837\u7684\u5e93\uff0c\u52a0\u4e0a\u81ea\u5b9a\u4e49 hooks \u5c01\u88c5\u903b\u8f91\uff0c\u4e5f\u662f\u53ef\u4ee5\u5f88\u6e05\u6670\u7684\uff0c\u751a\u81f3\u66f4\u7b80\u5355\uff0c\u5f53\u7136\u5bf9\u5f00\u53d1\u4eba\u5458\u7684\u8981\u6c42\u4e5f\u66f4\u9ad8\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286964\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : KuroNekoFan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4ec0\u4e48\u53eb\u5173\u6ce8\u70b9\u5206\u79bb\u554a(\u6218\u672f\u540e\u4ef0                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286965\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dartabe <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e3b\u8981\u662f\u81ea\u5b9a\u4e49 hooks \u5f88\u5f3a\u5927 \u6700\u8fd1\u7684\u611f\u89c9                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286966\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhuangzhuang1988 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6b63\u5e38, react-hook \u5fc3\u667a\u8d1f\u62c5 \u4e5f\u5f88\u5927, \u5f88\u5bb9\u6613\u51fa\u9519, \u800c\u4e14\u96be\u8c03\u8bd5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286967\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hoyixi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u662f\u6709\u9053\u7406\u7684\uff0cclass \u7ec4\u4ef6\u6bd4\u8f83\u6e05\u6670\uff0c\u53ef\u4ee5\u5199\u7684\u53c8\u81ed\u53c8\u957f\u3002<\/p>\n<p>\u5982\u679c\u4f60\u7684 functional \u7ec4\u4ef6\u5199\u7684\u5927\uff0cuseEffect \u91cc\u957f\u957f\u4e00\u5768\uff0c\u90a3\u4f60\u8be5\u8003\u8651\u63d0\u53d6\u529f\u80fd\u4e86\u3002\u4f8b\u5982\u4e0a\u9762\u670b\u53cb\u63d0\u5230\u7684\uff0c\u4e00\u4e9b\u5c0f\u529f\u80fd\u5c01\u88c5\u6210\u53ef\u91cd\u7528\u7684\u81ea\u5b9a\u4e49 hooks                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286968\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : liberty1900 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u8c08\u903b\u8f91\u62c6\u5c01\u8fd8\u5199\u4ec0\u4e48\u4ee3\u7801<br \/>\u76f8\u5173\u7684\u72b6\u6001\u5e94\u8be5\u5c01\u88c5\u6210\u5bf9\u8c61<br \/>\u60f3\u8981\u660e\u786e\u7684\u751f\u547d\u5468\u671f\u81ea\u5df1\u5c01\u88c5 useMount \u6216\u8005\u4f7f\u7528 react-use \u4e4b\u7c7b\u7684\u5e93<br \/>\u7528 hook \u6574\u4e2a\u601d\u7ef4\u65b9\u5f0f\u90fd\u8981\u6539\u53d8\uff0c\u4e0d\u8981\u8001\u60f3\u7740\u751f\u547d\u5468\u671f\uff0c\u8981\u60f3\u7740 synchronization. <br \/>\u4e3e\u4e86\u4e00\u4e2a\u4f8b\u5b50\u5c31\u51fa\u6765\u603c\u4e86\uff0c\u4f60\u8bf4\u6ca1\u6709\u660e\u786e\u7684 API, \u6211\u8fd8\u8bf4\u8fd9\u7cbe\u7b80\u4e86\u4e00\u4e2a API \u5462                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286969\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : murmur <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7c7b\u7ec4\u4ef6\u548c\u80e1\u514b\u65af\u672c\u8eab\u662f\u4e24\u79cd\u601d\u7ef4\u65b9\u5f0f\uff0c<\/p>\n<p>\u4f46\u662f react \u6709\u4e2a\u7279\u6b8a\u4e4b\u5904\uff0c\u5c31\u662f\u751f\u547d\u5468\u671f\u547d\u540d\u592a\u5c3c\u739b\u957f\u4e86\uff0c\u5b66 ios \u90a3\u4e00\u5957\u547d\u540d\uff0c\u524d\u7aef\u53c8\u6ca1\u6709 idea \u8fd9\u4e48\u725b\u903c\u7684 ide \u5e2e\u4f60\u81ea\u52a8\u8865\u5168\uff0c\u76f8\u6bd4\u4e4b\u4e0b vue \u5c31\u6ca1\u90a3\u4e48\u591a\u4e8b\uff0c\u522b\u4eba\u5c31\u662f\u6309\u7c7b\u7ec4\u4ef6\u5c01\u88c5\u4e5f\u6253\u4e0d\u4e86\u51e0\u4e2a\u5b57\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286970\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : murmur <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6240\u4ee5\u8bf4\u53c8\u56de\u5230\u8001\u751f\u5e38\u8c08\u7684\u95ee\u9898\u4e86\uff0c\u4ee3\u7801\u957f\u77ed\u548c\u8d28\u91cf\u3001\u8fd0\u884c\u6548\u7387\u6709\u5173\u4e48\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286971\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : love <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6ca1\u89c9\u5f97\u4ee3\u7801\u66f4\u6df7\u4e71\uff0c\u53cd\u800c\u80fd\u66f4\u597d\u7684\u62bd\u51fa\u516c\u5171\u90e8\u5206\uff0c\u4e0d\u8fc7 react hooks \u6709\u786c\u4f24\u5012\u662f\u771f\u7684\uff0c\u6709\u4e9b\u5730\u65b9\u6bd4\u8f83\u8d39\u8111\u5b50                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286972\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : nidaye999 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u53d1\u73b0\u6211\u559c\u6b22\u7528 react-hooks, \u4ee3\u7801\u903b\u8f91\u975e\u5e38\u6e05\u6670\u3002\u6211\u518d\u4e5f\u4e0d\u7528 class \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286973\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Jirajine <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             hooks \u624d\u662f react \u51fd\u6570\u5f0f\u7684\u7cbe\u9ad3\uff0cclass \u7ec4\u4ef6\u8fd8\u4e0d\u5982\u7528 vue \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286974\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : impl <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bb0\u5f97 svelte \u4f5c\u8005\u4e5f\u8bf4\u4ed6\u4e0d\u559c\u6b22 hook                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286975\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : duan602728596 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6700\u8fd1\u7684\u9879\u76ee\u5b8c\u5168\u4f7f\u7528 react-hook \u5f00\u53d1\uff0c\u662f\u771f\u7684\u8212\u670d\u3002<br \/> \u5728 react-hook \u91cc\u5c31\u4e0d\u8981\u60f3\u7740\u58f0\u660e\u5468\u671f\u90a3\u4e00\u5957\uff0c\u539f\u6765\u751f\u547d\u5468\u671f\u90a3\u4e00\u5806\u53cd\u800c\u5199\u8d77\u6765\u5f88\u4e71\u3002<br \/> \u62ff useEffect \u548c\u751f\u547d\u5468\u671f\u51fd\u6570\u505a\u5bf9\u6bd4\uff0c\u662f\u4e3a\u4e86\u8ba9\u5f00\u53d1\u8005\u80fd\u4e86\u89e3 useEffect\uff0c\u5728 class \u7ec4\u4ef6\u548c function \u7ec4\u4ef6\u5185\u5982\u4f55\u5b9e\u73b0\u76f8\u540c\u7684\u529f\u80fd\u3002<\/p>\n<p>&#8220;`javascript<\/p>\n<p>\/\/ class<br \/>class ClassComponent extends React.Component {<br \/> constructor() {<br \/> super();<\/p>\n<p> this.state = {<br \/> data: this.props.data,<br \/> list: []<br \/> };<br \/> }<\/p>\n<p> componentDidUpdate(prevProps, prevState) {<br \/> if (this.props.data !== prevProps.data) {<br \/> \/\/ do something<br \/> }<\/p>\n<p> if (this.state.list !== prevState.list) {<br \/> \/\/ do something<br \/> }<\/p>\n<p> if (this.props.data !== this.state.data) {<br \/> \/\/ do something<br \/> }<br \/> }<\/p>\n<p> componentWillUnmount() {<br \/> \/\/ do something 1<br \/> \/\/ do something 2<br \/> }<br \/>}<\/p>\n<p>\/\/ function hook<br \/>function FunctionComponent(props) {<br \/> const [list, setList] = React.useState([]);<\/p>\n<p> React.useEffect(function() {<br \/> \/\/ do something<\/p>\n<p> return function() {};<br \/> }, [props.data]);<\/p>\n<p> React.useEffect(function() {<br \/> \/\/ do something<br \/> }, [list]);<br \/>}<\/p>\n<p>&#8220;`<\/p>\n<p>class \u7ec4\u4ef6\u7684\u58f0\u660e\u5468\u671f\u662f\u6e32\u67d3 \/\u91cd\u65b0\u6e32\u67d3 \/\u7ec4\u4ef6\u5378\u8f7d\u65f6\uff0c\u4f60\u9700\u8981\u81ea\u5df1\u6765\u5224\u65ad\u662f\u54ea\u4e9b\u503c\u53d8\u4e86\uff0c\u54ea\u4e9b\u503c\u6ca1\u53d8\uff0c\u6240\u4ee5\u5728 class \u7ec4\u4ef6\u7684\u751f\u547d\u5468\u671f\u5185\u53ef\u80fd\u4f1a\u5145\u65a5\u7740\u4e00\u5806\u7684 if else \u7684\u5224\u65ad\u3002<br \/> function \u7ec4\u4ef6\u7684\u6e32\u67d3 \/\u91cd\u65b0\u6e32\u67d3 \/\u7ec4\u4ef6\u5378\u8f7d\uff0c\u662f\u7531\u54ea\u4e2a\u503c\u7684\u53d8\u5316\u5f15\u8d77\u7684\uff0c\u7136\u540e\u6267\u884c\u8fd9\u4e2a\u503c\u88ab\u4f9d\u8d56\u7684 hook\uff0c\u5373\u5f53\u8fd9\u4e2a\u503c\u53d8\u5316\u65f6\uff0c\u6267\u884c\u4ec0\u4e48\u64cd\u4f5c\uff0c\u53cd\u800c\u66f4\u4e00\u76ee\u4e86\u7136\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286976\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lemon6 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             hooks \u7684\u4f18\u70b9\u5c31\u662f\u4ee3\u7801\u91cf\u5c11\uff0c\u6211\u4e2a\u4eba\u8fd8\u662f\u559c\u6b22\u7528 class \u56e0\u4e3a\u7ec4\u4ef6\u7ed3\u6784\u53ef\u4ee5\u770b\u7684\u5f88\u6e05\u6670 \u4e5f\u5bb9\u6613\u7ef4\u62a4                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286977\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hgjian <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lemon6 \u51cc\u6668\u4e00\u70b9\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286978\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lihongming <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u575a\u6301\u4e00\u4e0b\uff0c\u4e60\u60ef\u5c31\u597d\u4e86\u3002\u6211\u5f00\u59cb\u4e5f\u4e0d\u559c\u6b22\uff0c\u73b0\u5728\u4e24\u79cd\u5199\u6cd5\u90fd\u65e0\u611f\u4e86\uff0c\u56e2\u961f\u9700\u8981\u600e\u4e48\u5199\uff0c\u6211\u5c31\u600e\u4e48\u5199\u3002<\/p>\n<p>\u6211\u4ece\u5f00\u53d1\u8005\u7684\u89d2\u5ea6\u611f\u89c9\u4e0d\u51fa\u660e\u663e\u7684\u597d\u574f\uff0c\u4f46\u4f20\u8bf4 hooks \u7684\u8fd0\u884c\u901f\u5ea6\u5feb 30%\uff0c\u6240\u4ee5\u65b0\u9879\u76ee\u591a\u7528 hooks                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286979\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Procumbens <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @murmur #7<br \/>\u4ec0\u4e48\u53eb\u6ca1\u6709 idea \u8fd9\u4e48\u725b\u903c\u7684 ide \u5e2e\u4f60\u81ea\u52a8\u8865\u5168 VS Code + ES 7 React\/Redux\/GraphQL\/React-Native snippets \u6253\u4e2a c \u5c31\u53ef\u4ee5\u9009\u62e9 lifecycle function \u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286980\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : timicoder <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u662f\u4e0d\u662f\u5c31\u662f class \u7684\u7ee7\u627f\u5440                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286981\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ruandao <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8981\u4e0d\u4f60\u8bd5\u8bd5 mobx                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286982\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wxsm <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             hooks \u786e\u5b9e\u662f\u4e00\u79cd\u8fdb\u6b65\uff0cclass \u7ee7\u627f\u590d\u7528\u662f\u786c\u4f24\u3002\u4f46\u662f hooks \u5b66\u4e60\u6210\u672c\u8f83\u9ad8\uff0c\u5982\u679c\u6ca1\u6709\u900f\u5f7b\u7684\u7406\u89e3\uff0c\u534a\u8def\u4e0a\u8f66\u5f00\u53d1\u5f88\u5bb9\u6613\u6389\u8fdb\u5751\u91cc\u3002\u8fd9\u4e00\u70b9\u4e0d\u5982 class \u660e\u6717\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286983\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wxsm <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u4e3e\u4e00\u4e2a\u5e38\u89c1\u7684\u4f8b\u5b50\uff0c\u4f60\u8981\u5982\u4f55\u5728 usecallback \u91cc\u9762\u8bbf\u95ee\u53d8\u5316\u7684 state \uff1f\u4e5f\u8bb8\u521d\u5b66\u8005\u4f1a\u89c9\u5f97\u76f4\u63a5\u8bbf\u95ee\u5c31\u53ef\u4ee5\u4e86\uff0c\u4f46\u662f\u5b9e\u9645\u4e0a\u4e0d\u884c\u3002\u4f60\u5fc5\u987b\u7528 useref \u518d\u5bf9 state \u8fdb\u884c\u4e00\u6b21\u5305\u88c5\uff0c\u4e0d\u7136\u53d6\u5230\u7684\u6c38\u8fdc\u662f state \u7684\u521d\u59cb\u503c\u3002\u7279\u522b\u9ebb\u70e6\u3002\u76f8\u6bd4\u6765\u8bf4\uff0cclass \u5c31\u7b80\u6d01\u660e\u6717\u5f97\u591a\u3002\u6709\u4e9b\u4eba\u5c31\u662f\u65e0\u7406\u7531\u5730\u559c\u6b22\u51fd\u6570\u5f0f\u7ec4\u4ef6\uff0c\u7b80\u76f4\u8ddf\u5904\u5973\u60c5\u7ed3\u4e00\u6837\uff0c\u6211\u89c9\u5f97\u5927\u53ef\u4e0d\u5fc5\uff0c\u8fd9\u4e8b\u8981\u8fa9\u8bc1\u5730\u770b\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286984\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : amundsen <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u5199 hooks \u5199\u7684\u5f88\u723d\uff0cclass \u7ec4\u4ef6\u5b8c\u5168\u88ab\u629b\u5f03\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286985\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : vision1900 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f7f\u7528\u81ea\u5b9a\u4e49 hook \u65f6\u5019\u7b80\u76f4\u50cf\u9b54\u6cd5<br \/>\u9b54\u6cd5\u662f\u4e2a\u597d\u4e1c\u897f\uff0c\u56e0\u4e3a\u795e\u5947<br \/>\u9b54\u6cd5\u4e0d\u662f\u4e2a\u597d\u4e1c\u897f\uff0c\u56e0\u4e3a\u795e\u5947                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286986\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : StephenHe <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u611f\u89c9\u662f class \u8ddf hooks \u4e00\u8d77\u7528\u7684\u95ee\u9898\u3002\u5efa\u8bae\u9879\u76ee\u5355\u7528 class \u3001\u5355\u7528 hooks \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286987\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : mxT52CRuqR6o5 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5b98\u65b9\u8bf4\u662f\u63a8\u8350\u65b0\u4ee3\u7801\u5168\u90e8\u7528 hooks\uff0c\u6211\u4e2a\u4eba\u7684\u5b9e\u9645\u4f53\u9a8c\u662f\u7528 hooks \u8981\u628a class component \u7684\u751f\u547d\u5468\u671f\u90a3\u5957\u4e1c\u897f\u5168\u90fd\u5fd8\u6389\uff0c\u5c31\u50cf\u5f20\u4e09\u4e30\u5b66\u592a\u6781\u62f3\u90a3\u6837                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286988\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : haleyao <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             react-hooks \u8fd9\u4e48\u597d\u7528\u7684\u4e1c\u897f\u90fd\u53d8\u6210\u5fc3\u667a\u8d1f\u62c5\u4e86\uff0c\u4f60\u4eec\u5f00\u53d1\u8005\u771f\u96be\u4f3a\u5019                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286989\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : azcvcza <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @wxsm \u4e0d\u7528 ref\uff0c\u73a9\u5b9a\u65f6\u5668\u603b\u662f\u4f1a\u51fa\u9519\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286990\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : devwolf <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @murmur \u786e\u5b9e\u662f\u4e24\u79cd\u601d\u7ef4\u65b9\u5f0f\u554a\uff0c\u8fd9\u70b9\u65e0\u53ef\u539a\u975e\u3002<br \/>\u4f46\u8981\u8bf4\u751f\u547d\u5468\u671f\u540d\u79f0\u592a\u957f\u4e0d\u63d0\u4f9b\u8865\u5168\uff0c\u4e0b\u4e5f\u8bf4\u4e86 vs code \u6253\u4e0a\u63d2\u4ef6\u7167\u6837\u53ef\u4ee5\u8865\u5168\u3002\u7ecf\u5e38\u5fd9 react \u5f00\u53d1\u7684\u90fd\u80fd\u8bb0\u5f97\u5e38\u7528\u7684\u751f\u547d\u5468\u671f\u5427\uff0c\u547d\u540d\u633a\u89c4\u5f8b\u7684\u2026\u2026<\/p>\n<p>@Jirajine \u6211\u8fd8\u5728\u60f3\u6211\u4e3a\u4ec0\u4e48\u6bd4\u8d77 hooks \u66f4\u80fd\u63a5\u53d7 class \u7ec4\u4ef6\uff0c\u8fd9\u4e48\u770b\u6765\u8fd8\u771f\u53ef\u80fd\u56e0\u4e3a\u65e9\u671f vue \u7684\u718f\u9676(\u6211\u4e2a\u4eba\u662f\u5148\u63a5\u89e6\u7684 vue \u5e94\u4ed8\u7684\u6bd5\u8bbe\uff0c\u7136\u540e\u9762\u5230\u516c\u53f8\u8ba9\u81ea\u5b66\u8f6c react \u4e86)                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286991\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : devwolf <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             lz \u52a0\u6cb9\uff0c\u5171\u52c9\u5427\u3002<br \/>\u6211\u81ea\u5df1\u4e5f\u77e5\u9053 hooks \u662f\u4e2a\u597d\u4e1c\u897f\uff0c\u52a0\u4e0a\u4e0a\u7684\u5927\u4f6c\u4eec\u4e5f\u90fd\u5206\u6790\u4e86\uff0c\u65e9\u5b66\u4f1a\u65e9\u5347\u503c\u5965                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286992\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : murmur <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @duan602728596 \u8fd9\u91cc\u53c8\u6709\u4e00\u4e2a\u8001\u751f\u5e38\u8c08\u7684\u95ee\u9898\uff0c\u5c31\u662f useXXX \u5224\u65ad\u53d8\u91cf\u53d8\u5316\u7684\u6bd4\u8f83\u6807\u51c6\u662f\u4ec0\u4e48\uff0c\u65b0\u4e1c\u897f\u80af\u5b9a\u4f1a\u6709\u65b0\u5751\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286993\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : namelosw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u4e0d\u559c\u6b22\u662f\u56e0\u4e3a\u4f60\u4e0d\u61c2\u51fd\u6570\u5f0f\u7f16\u7a0b\uff0c\u5e76\u4e0d\u662f class \u7684\u53ef\u7ef4\u62a4\u6027\u66f4\u597d\u3002\u5b9e\u9645\u4e0a class \u7684\u53ef\u7ef4\u62a4\u6027\u66f4\u5dee\u3002<\/p>\n<p>\u8981\u5b8c\u5168\u878d\u4f1a\u8d2f\u901a\u53ef\u4ee5\u7ec3\u4e00\u7ec3 OCaml \u3002React \u662f\u7528 SML \u548c OCaml \u5199\u7684\u539f\u578b\uff0chooks \u53ef\u4ee5\u7b97\u662f\u56de\u5f52\u521d\u5fc3\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286994\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Philippa <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             hooks \u6211\u559c\u6b22\uff0c\u592a\u591a\u903b\u8f91\u5c31\u81ea\u5b9a\u4e49 hooks\uff0c\u53ea\u8981\u6392\u597d\u7248\u5408\u7406\u5206\u62c6\u5176\u5b9e\u4e24\u79cd\u5199\u6cd5\u533a\u522b\u4e0d\u5927\u3002\u4e0d\u8fc7\u4e3b\u8d34\u7684 vue \u770b\u8d77\u6765\u4e5f\u4e0d\u9519\u554a\uff0c\u53ef\u8981\u6211\u9009\u8fd8\u662f\u7528 hooks\uff0c\u4e00\u822c\u6211\u5f88\u6392\u65a5\u5305\u542b\u6709\u5c5e\u6027\u4e4b\u7c7b\u7684\u4e1c\u897f\uff0c\u89c9\u5f97 hooks \u548c\u7eaf\u51fd\u6570\u5199\u8d77\u6765\u5c11\u70b9\u5fc3\u667a\u8d1f\u62c5\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u53d1\u73b0\u6211\u4e0d\u559c\u6b22\u7528 react-ho&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/155385"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=155385"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/155385\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=155385"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=155385"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=155385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}