{"id":4522,"date":"2023-01-04T15:56:07","date_gmt":"2023-01-04T07:56:07","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=4522"},"modified":"2023-01-04T15:56:07","modified_gmt":"2023-01-04T07:56:07","slug":"%e5%ad%b8%e7%bf%92react-js%e4%b8%ad%e7%9a%84%e7%8b%80%e6%85%8bstate","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/react-js\/%e5%ad%b8%e7%bf%92react-js%e4%b8%ad%e7%9a%84%e7%8b%80%e6%85%8bstate\/","title":{"rendered":"\u5b78\u7fd2React.js\u4e2d\u7684\u72c0\u614b(State)"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"React, React \u72c0\u614b(state)\"><\/p>\n<h1>React \u72c0\u614b(state)<\/h1>\n<p>React \u72c0\u614b(state)\u662f React \u61c9\u7528\u7a0b\u5f0f\u4e2d\u6700\u91cd\u8981\u7684\u6982\u5ff5\u4e4b\u4e00\uff0c\u5b83\u53ef\u4ee5\u8b93\u4f60\u5728\u61c9\u7528\u7a0b\u5f0f\u4e2d\u5132\u5b58\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002<\/p>\n<p>React \u72c0\u614b(state)\u662f\u4e00\u500b JavaScript \u7269\u4ef6\uff0c\u5b83\u53ef\u4ee5\u5728\u7d44\u4ef6\u4e2d\u88ab\u8a2d\u5b9a\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u7d44\u4ef6\u4e2d\u88ab\u66f4\u65b0\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">state = {\n  name: 'John',\n  age: 25\n};\n<\/code><\/pre>\n<p>React \u72c0\u614b(state)\u53ef\u4ee5\u88ab\u7528\u4f86\u5132\u5b58\u7d44\u4ef6\u7684\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u5171\u4eab\u8cc7\u6599\u3002\u5b83\u53ef\u4ee5\u88ab\u7528<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2React.js\u4e2d\u7684\u72c0\u614b(State)\uff0c\u4e86\u89e3\u5982\u4f55\u4f7f\u7528React.js\u4e2d\u7684state\u4f86\u63a7\u5236\u7db2\u9801\u5143\u4ef6\u7684\u884c\u70ba\uff0c\u4e26\u63d0\u5347\u7db2\u9801\u7684\u4f7f\u7528\u8005\u9ad4\u9a57\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[184,183],"tags":[182,181],"class_list":["post-4522","post","type-post","status-publish","format-standard","hentry","category-react","category-react-js","tag-react","tag-react-js"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pcFK27-1aW","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4522","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/comments?post=4522"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4522\/revisions"}],"predecessor-version":[{"id":4523,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4522\/revisions\/4523"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=4522"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=4522"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=4522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}