{"id":13251,"date":"2021-02-20T11:43:58","date_gmt":"2021-02-20T02:43:58","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=13251"},"modified":"2023-05-27T22:12:57","modified_gmt":"2023-05-27T13:12:57","slug":"%e3%80%90react%e3%80%91%e3%80%8c%e5%ad%90%e3%82%b3%e3%83%b3%e3%83%9d%e3%83%bc%e3%83%8d%e3%83%b3%e3%83%88%e3%80%8d%e3%81%8b%e3%82%89%e3%80%8c%e8%a6%aa%e3%82%b3%e3%83%b3%e3%83%9d%e3%83%bc%e3%83%8d","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=13251","title":{"rendered":"\u3010React\u3011\u300c\u5b50\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u300d\u304b\u3089\u300c\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u300d\u3078\u306e\u5024\u6e21\u3057"},"content":{"rendered":"<h2>string\u306e\u5024\u3092\u6e21\u3059\u3002<\/h2>\n<p>useState\u3067\u5b9a\u7fa9\u3057\u305f\u95a2\u6570\u3092\u5b50\u306b\u6e21\u3057\u3066\u5b50\u304b\u3089\u95a2\u6570\u3092\u547c\u3079\u3070\u89aa\u306e\u72b6\u614b\u3082\u5909\u66f4\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<\/h3>\n<pre class=\"lang:default decode:true\">import Child from '.\/Child';\r\nimport React from 'react';\r\n\r\nfunction Parent() {\r\n  const [value, setValue] = React.useState(\"\")\r\n  return (\r\n    &lt;div className=\"App\"&gt;\r\n      \u89aa\u8981\u7d20\r\n      &lt;Child setValue = {setValue} \/&gt;\r\n      {value}\r\n    &lt;\/div&gt;\r\n  );\r\n}\r\n\r\nexport default Parent;<\/pre>\n<h3>\u5b50\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<\/h3>\n<pre class=\"lang:default decode:true\">function Child(props) {\r\n  const message = '\u30c6\u30b9\u30c8'\r\n  return (\r\n    &lt;div className=\"App\"&gt;\r\n      \u5b50\u8981\u7d20\r\n      &lt;p&gt;{props.setValue(message)}&lt;\/p&gt;\r\n    &lt;\/div&gt;\r\n  );\r\n}\r\n\r\nexport default Child;<\/pre>\n<h2>\u914d\u5217\u306e\u5024\u3092\u6e21\u3059\u3002<\/h2>\n<p>\u914d\u5217\u306e\u5834\u5408\u3082\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308c\u3070\u5024\u3092\u6e21\u305b\u307e\u3059\u3002\u300c...value\u300d\u3068\u3057\u3066\u3044\u308b\u306e\u306f['\u3042','\u3044','\u3046']\u3068\u3044\u3046\u914d\u5217\u304c\u3042\u308c\u3070\u4e2d\u8eab\u306e\u300c'\u3042','\u3044','\u3046'\u300d\u3092\u5c55\u958b\u3057\u305f\u4e0a\u3067\u305d\u306e\u5f8c\u308d\u306b\u3064\u3044\u3066\u3044\u308b'\u3042'\u3092\u4ed8\u52a0\u3057\u305f\u65b0\u3057\u3044\u914d\u5217\u3092\u751f\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<\/h3>\n<pre class=\"lang:default decode:true \">import Child from '.\/Child';\r\nimport React from 'react';\r\n\r\nfunction Parent() {\r\n  const [value, setValue] = React.useState([])\r\n  return (\r\n    &lt;div className=\"App\"&gt;\r\n      \u89aa\u8981\u7d20\r\n      &lt;Child onClick = {() =&gt; setValue([...value,'\u3042'])} \/&gt;\r\n      {value}\r\n    &lt;\/div&gt;\r\n  );\r\n}<\/pre>\n<h3>\u5b50\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<\/h3>\n<pre class=\"lang:default decode:true  \">function Child(props) {\r\n  const message = 2\r\n  return (\r\n    &lt;div className=\"App\"&gt;\r\n      \u5b50\u8981\u7d20\r\n      &lt;button onClick={props.onClick}&gt;\u30dc\u30bf\u30f3&lt;\/button&gt;\r\n    &lt;\/div&gt;\r\n  );\r\n}\r\n\r\nexport default Child;<\/pre>\n","protected":false},"excerpt":{"rendered":"string\u306e\u5024\u3092\u6e21\u3059\u3002 useState\u3067\u5b9a\u7fa9\u3057\u305f\u95a2\u6570\u3092\u5b50\u306b\u6e21\u3057\u3066\u5b50\u304b\u3089\u95a2\u6570\u3092\u547c\u3079\u3070\u89aa\u306e\u72b6\u614b\u3082\u5909\u66f4\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8 import Child from '.\/Child'; import Reac [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[116],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/13251"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13251"}],"version-history":[{"count":5,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/13251\/revisions"}],"predecessor-version":[{"id":20433,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/13251\/revisions\/20433"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13251"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}