{"id":177064,"date":"2020-10-21T00:05:08","date_gmt":"2020-10-20T16:05:08","guid":{"rendered":"http:\/\/4563.org\/?p=177064"},"modified":"2020-10-21T00:05:08","modified_gmt":"2020-10-20T16:05:08","slug":"%e8%af%b7%e6%95%99%e4%b8%80%e4%b8%aa%e6%9c%89%e5%85%b3-react-state-%e8%ae%be%e8%ae%a1%e5%92%8c%e4%bd%bf%e7%94%a8%e7%9a%84%e9%97%ae%e9%a2%98%ef%bc%9a%e5%a6%82%e4%bd%95%e6%9b%b4%e6%96%b0%e4%ba%86-state","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=177064","title":{"rendered":"\u8bf7\u6559\u4e00\u4e2a\u6709\u5173 react state \u8bbe\u8ba1\u548c\u4f7f\u7528\u7684\u95ee\u9898\uff1a\u5982\u4f55\u66f4\u65b0\u4e86 state\uff0c\u4f46\u4e0d\u89e6\u53d1\u9875\u9762\u66f4\u65b0\uff0c\u76f4\u5230\u4e0b\u4e00\u6b21\u91cd\u65b0\u6253\u5f00\u7f51\u7ad9\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bf7\u6559\u4e00\u4e2a\u6709\u5173 react state \u8bbe\u8ba1\u548c\u4f7f\u7528\u7684\u95ee\u9898\uff1a\u5982\u4f55\u66f4\u65b0\u4e86 state\uff0c\u4f46\u4e0d\u89e6\u53d1\u9875\u9762\u66f4\u65b0\uff0c\u76f4\u5230\u4e0b\u4e00\u6b21\u91cd\u65b0\u6253\u5f00\u7f51\u7ad9\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yazoox <\/span>  <span><i><\/i> 1<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6280\u672f\u7528\u7684\u662f react, react-redux, and react-saga \u90a3\u4e00\u5957\u3002<\/p>\n<p>\u73b0\u5728\u8981\u505a\u591a\u8bed\u8a00\u652f\u6301\uff0c\u6240\u4ee5\uff0c\u7528\u6237\u8bbe\u7f6e\u91cc\u9762\u6709\u4e00\u9879\uff0c\u8bed\u8a00\u8bbe\u7f6e language settings. \u9ed8\u8ba4\u662f\u5f53\u524d\u6d4f\u89c8\u5668\u7684\u8bed\u8a00 locale \u3002\u4f46\u662f\u7528\u6237\u53ef\u4ee5\u4fee\u6539\u6210\u81ea\u5df1\u60f3\u8981\u4f7f\u7528\u7684\u4efb\u4f55\u8bed\u8a00\uff0c\u6bd4\u5982 \u65e5\u6587\uff0c\u4fc4\u8bed\uff0c\u4e2d\u6587\uff0c\u7b49\u7b49\u3002<\/p>\n<p>\u95ee\u9898\u6765\u4e86\uff0c\u5728 settings \u9875\u9762\uff0c\u7528\u6237\u9009\u62e9\u4e86\u81ea\u5b9a\u4e49\u7684 locale \u540e\uff0c\u8fd9\u4e2a\u503c\u6211\u4eec\u662f\u4f1a\u4fdd\u5b58\u4e0b\u6765\u7684\uff0c\u662f\u4f1a\u66f4\u65b0 state \u72b6\u6001\u7684\uff0c\u7136\u540e\u9875\u9762\u5c31\u5237\u65b0\u4e86\u3002\u800c\u4e14\uff0c\u5237\u65b0\u662f\u591a\u4e2a\u9875\u9762\u5237\u65b0\uff0c\u4e0d\u4ec5\u4ec5\u662f\u5f53\u524d\u8bbe\u7f6e\u9875\u9762\u3002\u53ef\u662f\uff0c\u6211\u4eec\u4e0d\u60f3\u8fd9\u6837\uff0c\u800c\u662f\u4fdd\u6301\u4e0d\u53d8\u3002\u76f4\u5230\u7528\u6237\u4e0b\u4e00\u6b21\u6253\u5f00\u7f51\u7ad9\uff0c\u91cd\u65b0\u52a0\u8f7d\u65f6\uff0c\u53d1\u73b0 locale \u4f7f\u7528\u4e86\u81ea\u5b9a\u4e49\u7684\uff0c\u7136\u540e\u4f7f\u7528\u65b0\u7684\u8bed\u8a00\u3002\uff08\u56e0\u4e3a\u6709\u4e9b\u529f\u80fd\uff0c\u5fc5\u987b\u7f51\u7ad9\u91cd\u65b0\u6253\u5f00\uff0c\u521d\u59cb\u5316\u65f6\u52a0\u8f7d\uff0c\u5176\u5b83\u8bed\u8a00\uff0c\u624d\u80fd\u591f\u6210\u529f\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5373\u4f7f\u5b9e\u65f6\u5237\u65b0\u9875\u9762\uff0c\u8fd9\u4e2a\u5237\u65b0\u662f\u4e0d\u5b8c\u6574\u7684\uff0c\u53ef\u80fd\u4f1a\u51fa\u95ee\u9898\uff09<\/p>\n<p>\u60f3\u8fc7\u6dfb\u52a0\u4e00\u4e2a\u4e34\u65f6\u7684 flag\uff0c\u5982\u679c\u4fee\u6539\u4e86\u8bed\u8a00\u8bbe\u7f6e\uff0c\u5219\u8bbe\u7f6e\u4e3a 1. \u7136\u540e react \u5237\u65b0\u65f6\uff0c\u5982\u679c\u53d1\u73b0\u4e3a 1\uff0c\u8bed\u8a00\u4e0d\u53d8\uff0c\u8fd8\u662f\u4e0a\u6b21\u7684\uff08\u90a3\u8fd8\u5f97\u6709\u6dfb\u52a0\u4e00\u4e2a readonly \u7684 state\uff0c\u8bb0\u5f55\u7f51\u7ad9\u6253\u5f00\u65f6\u7684\u90a3\u4e2a\u8bed\u8a00\uff09\u3002\u800c\u4e14\uff0cstate \u7684\u662f react engine \u81ea\u52a8\u5237\u65b0\u7684\uff0c\u6ca1\u6709\u592a\u597d\u7684\u529e\u6cd5\u63a7\u5236\u5b83\u3002<\/p>\n<p>\u7279\u6765\u8bf7\u6559\u4e00\u4e0b\u5927\u5bb6\uff0c\u6709\u6ca1\u6709\u6bd4\u8f83\u6210\u719f \/\u5408\u9002\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>9<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3914502\" 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>                                                             \u90a3\u4e3a\u4ec0\u4e48\u8981\u7528 state \u5462\uff0c\u505a\u6210\u5e38\u91cf\u4e0d\u597d\u4e48\uff0c\u6bcf\u6b21\u66f4\u65b0\u53ea\u5728\u540e\u53f0\u53d8\u66f4\u914d\u7f6e\uff0c\u505a\u6210 state \u5c31\u662f\u8981\u8054\u52a8\u66f4\u65b0                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3914503\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : shintendo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7f13\u7f13\u6253\u51fa\u4e86\u4e00\u4e2a\u95ee\u53f7                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3914504\" 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>                                                             SPA \u600e\u4e48\u505a\u5230\u591a\u9875\u9762\u7684\uff0c\u5728\u7ebf\u7b49                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3914505\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yhxx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bed\u8a00\u5b58\u4e2a localstorage \u4e0d\u884c\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3914506\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : source <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             cookie\uff0clocalstorage\uff0c\u4f60\u9700\u8981\u6301\u4e45\u5316\u5b58\u50a8\uff0c\u8ddf react \u8ddf\u6846\u67b6\u6ca1\u6709\u4efb\u4f55\u5173\u7cfb\uff0c\u4f60\u5199 jq \u4e5f\u662f\u8fd9\u4e2a\u601d\u8def\u6765\u5b9e\u73b0                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3914507\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : source <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8be6\u7ec6\u4e00\u70b9\u5c31\u662f\uff0ci18n \u914d\u7f6e\u5b58\u5728 localstorage \u91cc\uff0c\u9875\u9762 init \u7684\u65f6\u5019\u8bfb\u53d6 localstorage \u4e2d\u7684\u8bed\u8a00\u914d\u7f6e\u5c31\u5b8c\u4e8b\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3914508\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 996icu007007 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @vision1900 \u591a\u9875\u9762\u6253\u5305\u5417\uff1f \u914d\u4e2a webpack entery \u554a \u7f51\u4e0a\u641c\u591a\u7684\u662f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3914509\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : acfe <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528 localstorage \u554a\uff0c\u6216\u8005\u628a locale \u5b57\u6bb5\u5b58\u5230\u6570\u636e\u5e93\u91cc\uff0c\u4e0b\u4e00\u6b21\u6253\u5f00\uff0c\u518d\u53bb\u8c03\u63a5\u53e3\u62ff\u8fd9\u4e2a\u5b57\u6bb5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3914510\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : GzhiYi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5355\u7eaf\u7684 state \u662f\u6ca1\u6cd5\u6301\u4e45\u5316\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u6559\u4e00\u4e2a\u6709\u5173 react stat&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\/177064"}],"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=177064"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/177064\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=177064"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=177064"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=177064"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}