{"id":1541,"date":"2017-04-13T11:41:48","date_gmt":"2017-04-13T02:41:48","guid":{"rendered":"http:\/\/lovelinux.mydns.jp\/?p=1541"},"modified":"2017-04-13T11:41:48","modified_gmt":"2017-04-13T02:41:48","slug":"reactjs%e3%81%93%e3%81%a8%e3%81%af%e3%81%98%e3%82%81-vol-2-2","status":"publish","type":"post","link":"https:\/\/lovelinux.mydns.jp\/?p=1541","title":{"rendered":"ReactJS\u3053\u3068\u306f\u3058\u3081 vol.2"},"content":{"rendered":"<p>\u3067\u306f ReactJS \u7b2c\uff12\u56de\u76ee\u3044\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\n\u4eca\u56de\u306f\u4e0b\u56f3\u306e\u3088\u3046\u306a\u611f\u3058\u304c\u5b8c\u6210\u56f3\u3067\u3059\u3002<\/p>\n<p><a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo1.png\" alt=\"todo1\" width=\"411\" height=\"199\" class=\"alignnone size-full wp-image-1299\" srcset=\"https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo1.png 411w, https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo1-300x145.png 300w\" sizes=\"auto, (max-width: 411px) 100vw, 411px\" \/><\/a><\/p>\n<p>\u5358\u7d14\u306bToDo\u304c\u4e00\u89a7\u3055\u308c\u3066\u304a\u308a\u3001ToDo\u306e\u6a2a\u306b\u306f\u524a\u9664\u30dc\u30bf\u30f3\u304c\u3042\u308a\u3002<br \/>\nToDo\u3092\u8ffd\u52a0\u3057\u305f\u3044\u5834\u5408\u306f\u4e0a\u90e8\u306e\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306b\u6587\u5b57\u3092\u5165\u529b\u3057<br \/>\n\u8ffd\u52a0\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3002<\/p>\n<p>\u305f\u3063\u305f\u3053\u308c\u3060\u3051\u3067\u3059\u3002<br \/>\n\u307e\u3041\u3053\u306e\u305f\u3063\u305f\u3053\u308c\u3060\u3051\u304c\u7d50\u69cb\u96e3\u3057\u3044\u3093\u3067\u3059\u3051\u3069\u306d\u3002<\/p>\n<p>\u3067\u306f\u3044\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u307e\u305a\u306f\u521d\u671f\u5024\u3068\u306a\u308b\u5909\u6570\u3092\u3053\u3093\u306a\u611f\u3058\u3067\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n<p>[bash]<br \/>\n  var DATAS = [<br \/>\n    {id:1, content:&#8221;Softbank\u89e3\u7d04&#8221;},<br \/>\n    {id:2, content:&#8221;R-SIM10\u8cfc\u5165&#8221;},<br \/>\n    {id:3, content:&#8221;\u570f\u5916\u75c5\u3092\u514b\u670d\u3059\u308bSIM\u30d5\u30ea\u30fc\u30eb\u30fc\u30bf\u30fc\u30b2\u30c3\u30c8&#8221;},<br \/>\n    {id:4, content:&#8221;\u697d\u5929\u30e2\u30d0\u30a4\u30eb\u7533\u3057\u8fbc\u307f&#8221;}<br \/>\n  ]<br \/>\n[\/bash]<\/p>\n<p>\u3053\u306e\u5909\u6570\u304cToDo\u30ea\u30b9\u30c8\u306e\u521d\u671f\u5024\u3067\u3059\u3002<br \/>\n\u3067\u306f\u6b21\u3001\u753b\u9762\u30a4\u30e1\u30fc\u30b8\u304b\u3089\u3001\u4f55\u500b\u306e\u72ec\u81ea\u30af\u30e9\u30b9\u3092\u5b9a\u7fa9\u3057\u306a\u304d\u3083\u3044\u3051\u306a\u3044\u304b\u8003\u3048\u307e\u3057\u3087\u3046\u3002<br \/>\n\u7c21\u5358\u306b\u8a00\u3063\u3066\u307e\u3059\u304c\u3001\u3053\u308c\u304b\u306a\u308a\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\u3067\u3059\u3002<\/p>\n<h4>\u8981\u306f\u3069\u3093\u306a\u304c\u5b8c\u6210\u56f3\u304c\u3042\u308b\u304b\u3089\u3001\u3069\u3046\u3044\u3046\u30d1\u30fc\u30c4\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u753b\u9762\u3092\u4f5c\u308d\u3046\u304b\uff1f\uff1f<\/h4>\n<p>\u3068\u8003\u3048\u308b\u306e\u3067\u3059\u3002\u305d\u306e\u30d1\u30fc\u30c4\u304c class\u3067\u3042\u308a\u3001\u305d\u306e class\u304c\u72ec\u81ea\u30bf\u30b0\u306a\u3093\u3067\u3059\u306d\u3002<\/p>\n<p>ToDo\u30ea\u30b9\u30c8\u306f\u81f3\u3063\u3066\u30b7\u30f3\u30d7\u30eb\u3002<br \/>\nToDo\u306e\u4e00\u89a7\u3068\u306a\u308b\u30d1\u30fc\u30c4\u3002\u3053\u308c\u21d3\u21d3\u21d3\u3002<\/p>\n<p><a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo2-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo2-1.png\" alt=\"todo2\" width=\"373\" height=\"104\" class=\"alignnone size-full wp-image-1309\" srcset=\"https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo2-1.png 373w, https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo2-1-300x84.png 300w\" sizes=\"auto, (max-width: 373px) 100vw, 373px\" \/><\/a><\/p>\n<p>\u3068ToDo\u3092\u8ffd\u52a0\u3059\u308b\u305f\u3081\u306e\u30d1\u30fc\u30c4\u3002\u3053\u308c\u21d3\u21d3\u21d3\u3002<\/p>\n<p><a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo3-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo3-1.png\" alt=\"todo3\" width=\"395\" height=\"32\" class=\"alignnone size-full wp-image-1310\" srcset=\"https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo3-1.png 395w, https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo3-1-300x24.png 300w\" sizes=\"auto, (max-width: 395px) 100vw, 395px\" \/><\/a><\/p>\n<p>\u305d\u3057\u3066ToDo\u306e\u4e00\u89a7\u306e\u4e00\u884c\u3092\u69cb\u6210\u3059\u308b\u30d1\u30fc\u30c4\u3002\u3053\u308c\u21d3\u21d3\u21d3\u3002<\/p>\n<p><a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo4-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo4-1.png\" alt=\"todo4\" width=\"297\" height=\"22\" class=\"alignnone size-full wp-image-1311\" \/><\/a><\/p>\n<p>\u30d1\u30fc\u30c4\u306f\u6c7a\u307e\u308a\u307e\u3057\u305f\u306e\u3067\u3001\u3053\u306e\u30d1\u30fc\u30c4\u3092\u30af\u30e9\u30b9\u3068\u3057\u3066\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u6700\u521d\u306e\u30d1\u30fc\u30c4 ToDo\u4e00\u89a7\u3092\u3000DataList\u3002<br \/>\n\u6b21\u306bToDo\u3092\u8ffd\u52a0\u3059\u308b\u30d1\u30fc\u30c4\u3092 NewToDo\u3002<br \/>\nToDo\u306e\u4e00\u884c\u3092\u69cb\u6210\u3059\u308b\u30d1\u30fc\u30c4\u3092\u3000DataLine<br \/>\n\u6700\u5f8c\u306b\u3053\u308c\u3089\u5168\u90e8\u3092\u5305\u542b\u3059\u308b ToDoList\u3000\u3068\u3057\u307e\u3059\u3002<\/p>\n<p>\u56f3\u3067\u66f8\u304f\u3068\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo5.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo5.png\" alt=\"todo5\" width=\"500\" height=\"280\" class=\"alignnone size-full wp-image-1328\" srcset=\"https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo5.png 500w, https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/todo5-300x168.png 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>\u3067\u306f\u307e\u305aToDo\u4e00\u89a7\u3067\u3042\u308b\u3000DataList\u3092\u30af\u30e9\u30b9\u3068\u3057\u3066\u5b9a\u7fa9\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>[bash]<br \/>\n  class DataList extends React.Component{<br \/>\n    constructor(props){<br \/>\n      super(props);<br \/>\n    }<\/p>\n<p>    handleOnDelete(id){<br \/>\n      this.props.onDelete(id);<br \/>\n    }<\/p>\n<p>    render() {<br \/>\n      var dlist = [];<br \/>\n      var i;<\/p>\n<p>      for (i=0; i < this.props.datas.length; i++){\n        var data = this.props.datas[i];\n        dlist.push(<DataLine data={data} key={data.id} onDelete={(id) => this.handleOnDelete(id)}\/>);<br \/>\n      }<\/p>\n<p>      return (<\/p>\n<div id=\"dataList\">\n          {dlist}\n        <\/div>\n<p>      );<br \/>\n    }<br \/>\n  }<br \/>\n[\/bash]<\/p>\n<p>\u306a\u3093\u306e\u3053\u3068\u304b\u7406\u89e3\u3067\u304d\u307e\u3059\u304b\uff1f \u666e\u901a\u96e3\u3057\u3044\u306a\u3041\u3068\u601d\u3044\u307e\u3059\u3088\u306d\u3002<\/p>\n<p>\u30af\u30e9\u30b9\u5b9a\u7fa9\u306e\u8aac\u660e\u306f HelloWorld\u3092\u51fa\u529b\u3059\u308b\u90e8\u5206\u3067\u3084\u3063\u305f\u306e\u3067\u5272\u611b\u3057\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f \u6b21\u306econstructor\u3000\u3068\u306f\u4f55\u3067\u3057\u3087\u3046\u304b\u30fb\u30fb\u30fb<br \/>\n\u8981\u306f\u30af\u30e9\u30b9\u306e\u521d\u671f\u5316\u51e6\u7406\u3092\u3053\u3053\u3067\u884c\u3044\u307e\u3059\u3088\u3000\u3068\u3044\u3046\u3053\u3068\u306a\u306e\u3067\u3059\u304c\u30fb\u30fb<br \/>\n\u521d\u671f\u5316\u3067\u3059\u308b\u3053\u3068\u306f\u7279\u306b\u306a\u3044\u306e\u3067\u3001\u304a\u6c7a\u307e\u308a\u306e\u304a\u307e\u3058\u306a\u3044 super(props)\u3060\u3051\u3092\u8a18\u8ff0\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>[bash]<br \/>\n    constructor(props){<br \/>\n      super(props);<br \/>\n    }<br \/>\n[\/bash]<\/p>\n<p>\u6b21\u306e handleOnDelete \u3053\u308c\u306a\u3093\u3067\u3059\u304c\u30fb\u30fb \u5fc5\u8981\u3067\u3059\u304c\u3001\u3053\u306e\u8aac\u660e\u306f\u5f8c\u56de\u3057\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>[bash]<br \/>\n   handleOnDelete(id){<br \/>\n      this.props.onDelete(id);<br \/>\n    }<br \/>\n[\/bash]<\/p>\n<p>\u6700\u5f8c\u306b render\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<br \/>\nHelloWorld\u3067\u3082\u3084\u3063\u305f\u3088\u3046\u306b\u3001render\u30e1\u30bd\u30c3\u30c9\u3067\u3001\u3053\u306e\u30af\u30e9\u30b9\u304c\u51fa\u529b\u3059\u308b<br \/>\nHTML\u30bf\u30b0\u3092\u69cb\u7bc9\u3059\u308b\u3093\u3067\u3059\u3002<\/p>\n<p>ToDo\u306e\u4e00\u89a7\u306a\u3093\u3067\u3001\u3053\u306e\u30af\u30e9\u30b9\u3092\u4f5c\u308b\u3068\u304d\u306bToDo\u306e\u4e00\u89a7\u3068\u306a\u308b\u30c7\u30fc\u30bf\u3092\u5f15\u304d\u6e21\u3057\u3066\u3082\u3089\u3046\u3053\u3068\u3092\u60f3\u5b9a\u3057\u307e\u3059\u3002<br \/>\n\u305d\u308c\u304c\u3000this.props.datas\u3000\u3068\u3044\u3046\u5909\u6570\u3067\u53c2\u7167\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>render\u30e1\u30bd\u30c3\u30c9\u306e\u4e2d\u3067\u306f\u3001\u3053\u306e\u5909\u6570\u3092\u30eb\u30fc\u30d7\u3067\u56de\u3057\u3066\u3001 dlist\u3068\u3044\u3046\u5909\u6570\u306b push\u3057\u3066\u3044\u3063\u3066\u307e\u3059\u3002<br \/>\npush\u3059\u308b\u5185\u5bb9\u306f\u3001ToDo\u306e\uff11\u884c\u3092\u69cb\u6210\u3059\u308b DataLine\u30bf\u30b0\uff08\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\uff09\u3067\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066 render\u30e1\u30bd\u30c3\u30c9\u304c\u30ea\u30bf\u30fc\u30f3\u3059\u308b\u5185\u5bb9\u306f &lt;div&gt;\u30bf\u30b0\u306e\u4e2d\u306b\u4e0a\u8a18\u306e\u914d\u5217\u5909\u6570\u3092\u7d44\u307f\u8fbc\u3093\u3060\u3082\u306e\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>[bash]<br \/>\n    render() {<br \/>\n      var dlist = [];<br \/>\n      var i;<\/p>\n<p>      for (i=0; i < this.props.datas.length; i++){\n        var data = this.props.datas[i];\n        dlist.push(<DataLine data={data} key={data.id} onDelete={(id) => this.handleOnDelete(id)}\/>);<br \/>\n      }<\/p>\n<p>      return (<\/p>\n<div id=\"dataList\">\n          {dlist}\n        <\/div>\n<p>      );<br \/>\n    }<br \/>\n[\/bash]<\/p>\n<p>\u809d\u5fc3\u306a\u3053\u3068\u3092\u5fd8\u308c\u3066\u3044\u307e\u3057\u305f\u3002<br \/>\n\uff13\u3064\u306e\u30d1\u30fc\u30c4\u3092\u5305\u542b\u3059\u308b\u4e00\u756a\u5927\u304d\u306a\u30d1\u30fc\u30c4\u304c\u5fc5\u8981\u3067\u3059\u3002\u3053\u308c\u3092ToDoList\u30af\u30e9\u30b9\u3068\u3057\u307e\u3059\u3002<br \/>\nToDoList\u30af\u30e9\u30b9\u306e\u30bd\u30fc\u30b9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>[bash]<br \/>\n  class ToDoList extends React.Component{<br \/>\n    constructor(props){<br \/>\n      super(props);<\/p>\n<p>      this.state = {<br \/>\n        datas: props.datas<br \/>\n      }<br \/>\n    }<\/p>\n<p>    render(){<br \/>\n      return (<\/p>\n<div id=\"toDoList\">\n          <NewToDo \/><br \/>\n          <DataList datas={this.state.datas} \/>\n        <\/div>\n<p>      );<br \/>\n    }<br \/>\n  }<br \/>\n[\/bash]<\/p>\n<p>ToDoList\u30af\u30e9\u30b9\u306e render\u30e1\u30bd\u30c3\u30c9\u3067\u306f\u3001NewToDo\u30bf\u30b0\u3068DataList\u30bf\u30b0\u3092\u69cb\u7bc9\u3057\u3066\u3044\u308b\u306e\u304c\u89e3\u308b\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u305d\u3057\u3066 DataList\u30bf\u30b0\u306e datas\u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u306b this.state.datas\u3000\u3092\u6e21\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\nthis.state.datas\u3000\u3068\u306f\u4f55\u3067\u3057\u3087\u3046\u304b\uff1f<br \/>\nstate\u3068\u306f\u30af\u30e9\u30b9\u304c\u7ba1\u7406\u3059\u308b\u52d5\u7684\u306a\u5909\u6570\u306e\u3088\u3046\u306a\u3082\u306e\u3067\u3059\u3002<\/p>\n<h4>ReactJS\u3067\u306f state\u306e\u5024\u304c\u5909\u66f4\u3055\u308c\u308b\u3068\u3001\u81ea\u52d5\u7684\u306b\u305d\u306estate\u306e\u5024\u304c\u6307\u3057\u793a\u3059 HTML\u3092\u66f8\u304d\u63db\u3048\u308b\u4ed5\u7d44\u307f<\/h4>\n<p>\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3059\u3002<\/p>\n<p>\u3067\u3001\u5b9f\u969b\u306b\u3053\u3053\u3067\u306f\u3000this.state.datas\u3000\u306b\u4f55\u304c\u5165\u3063\u3066\u3044\u308b\u304b\u3068\u3044\u3046\u3068\u3001\u6700\u521d\u306e\u65b9\u3067\u8aac\u660e\u3057\u305f<br \/>\nToDo\u30ea\u30b9\u30c8\u306e\u4e2d\u8eab\u3067\u3042\u308b DATAS\u5909\u6570\u304c\u5165\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3067\u306f\u8a00\u8449\u8db3\u3089\u305a\u3067\u3059\u306d\u3002<br \/>\nToDoList\u30af\u30e9\u30b9\u304c\u5168\u30af\u30e9\u30b9\u306e\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u30af\u30e9\u30b9\u3067\u3042\u308b\u306e\u3067\u3001<br \/>\nReactDOM.render \u3067\u306f\u3000ToDoList\u30af\u30e9\u30b9\u3092\u3000render\u3057\u3066\u3082\u3089\u3044\u307e\u3059\u3002<br \/>\n\u30bd\u30fc\u30b9\u3067\u66f8\u304f\u3068\u3053\u3093\u306a\u611f\u3058\u3002<\/p>\n<p>[bash]<br \/>\nReactDOM.render(<br \/>\n   <ToDoList \/>,<br \/>\n   document.getElementById(&#8220;root&#8221;)<br \/>\n);<\/p>\n<p>[\/bash]<\/p>\n<p>\u3067\u3001\u3053\u308c\u3060\u3051\u3060\u3068\u3001ToDoList\u306e\u521d\u671f\u5024\u3092\u6e21\u305b\u3066\u3044\u306a\u3044\u3053\u3068\u306b\u306a\u308b\u306e\u3067\u3001<br \/>\n\u6b63\u3057\u304f\u306f\u3000\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u8981\u306f\u30af\u30e9\u30b9\u5185\u3067\u4f7f\u3044\u305f\u3044\u30c7\u30fc\u30bf\u306f \u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u3067\u6e21\u305d\u3046\u306d\u3002\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u3067\u3001\u30c7\u30fc\u30bf\u3068\u306f\u52d5\u7684\u306b\u5909\u5316\u3059\u308b\u3082\u306e\u306a\u306e\u3067\u3000\uff5b\uff5d\u3000\u3067\u62ec\u3063\u3066\u6e21\u305d\u3046\u306d\u3068\u3044\u3046\u30eb\u30fc\u30eb\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>[bash]<br \/>\n  var DATAS = [<br \/>\n    {id:1, content:&#8221;Softbank\u89e3\u7d04&#8221;},<br \/>\n    {id:2, content:&#8221;R-SIM10\u8cfc\u5165&#8221;},<br \/>\n    {id:3, content:&#8221;\u570f\u5916\u75c5\u3092\u514b\u670d\u3059\u308bSIM\u30d5\u30ea\u30fc\u30eb\u30fc\u30bf\u30fc\u30b2\u30c3\u30c8&#8221;},<br \/>\n    {id:4, content:&#8221;\u697d\u5929\u30e2\u30d0\u30a4\u30eb\u7533\u3057\u8fbc\u307f&#8221;}<br \/>\n  ]<\/p>\n<p>  ReactDOM.render(<br \/>\n    <ToDoList datas={DATAS} \/>,<br \/>\n    document.getElementById(&#8220;root&#8221;)<br \/>\n  );<br \/>\n[\/bash]<\/p>\n<p>\u3067\u3001\u307e\u3060\u3053\u308c\u3067\u3082 DataList\u30af\u30e9\u30b9\u306e\u3000this.props.datas\u3000\u306b DATAS\u306e\u5024\u304c\u6e21\u3063\u3066\u3044\u304f\u4ed5\u7d44\u307f\u304c\u8aac\u660e\u3067\u304d\u3066\u3044\u307e\u305b\u3093\u306d\u3002<br \/>\nDataList\u30af\u30e9\u30b9\u306f\u3000ToDoList\u30af\u30e9\u30b9\u306e\u5b50\u4f9b\u3067\u3059\u3002\u3064\u307e\u308a DataList\u30af\u30e9\u30b9\u306f ToDoList\u30af\u30e9\u30b9\u306erender\u30e1\u30bd\u30c3\u30c9\u3067<br \/>\n\u4f5c\u6210\u3055\u308c\u3001\u305d\u306e\u6642\u306bDataList\u30af\u30e9\u30b9\u304c\u6271\u3046\u5909\u6570\u3068\u3057\u3066 datas\u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u306b DATAS\u3092\u6e21\u3059\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u65e5\u672c\u8a9e\u3067\u66f8\u304f\u3068\u3084\u3084\u3053\u3057\u3044\u3067\u3059\u306d\u3002<br \/>\n\u3064\u307e\u308a\u306f\u3001ToDoList\u30af\u30e9\u30b9\u306erender\u30e1\u30bd\u30c3\u30c9\u3067\u306f\u3000\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u3053\u3068\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>[bash]<br \/>\n  class ToDoList extends React.Component{<br \/>\n    constructor(props){<br \/>\n      super(props);<br \/>\n      this.state = {<br \/>\n        datas: props.datas<br \/>\n      }<br \/>\n    }<\/p>\n<p>    render(){<br \/>\n      return (<\/p>\n<div id=\"toDoList\">\n          <NewToDo \/><br \/>\n          <DataList datas={this.state.datas} \/>\n        <\/div>\n<p>      );<br \/>\n    }<br \/>\n  }<\/p>\n<p>[\/bash]<\/p>\n<p>render\u30e1\u30bd\u30c3\u30c9\u306e\u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u3067\u6e21\u3055\u308c\u305f\u5909\u6570\u306f\u3001 \u30af\u30e9\u30b9\u5185\u3067 props\uff08\u30d7\u30ed\u30d1\u30c6\u30a3\uff09\u3068\u3057\u3066\u53c2\u7167\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<br \/>\nToDoList\u30af\u30e9\u30b9\u306f datas\u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u3067\u6e21\u3055\u308c\u305f DATAS\u5909\u6570\u306e\u4e2d\u8eab\u3092\u81ea\u8eab\u306e\u30af\u30e9\u30b9\u306e state\u3068\u3057\u3066\u7ba1\u7406\u3057\u3088\u3046\u3068\u3057\u307e\u3059\u3002<br \/>\n\u3053\u308c\u304c constructor\u306e\u4e2d\u306b\u3042\u308b\u3002<\/p>\n<p>this.state = {datas: this.props.datas};<\/p>\n<p>\u3053\u308c\u3067 ToDoList\u30af\u30e9\u30b9 \u5185\u3067\u306f this.state.datas \u3067 DATAS\u306e\u5185\u5bb9\u3092\u53c2\u7167\u3067\u304d\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u3084\u3063\u3068\u3053\u308c\u3067 DataList\u306b DATAS\u306e\u5024\u304c\u6e21\u308b\u3053\u3068\u304c\u8aac\u660e\u3067\u304d\u307e\u3057\u305f\u304b\u306d\u30fb\u30fb\u30fb<\/p>\n<p>\u3067\u306f\u3001\u6b21\u306fDataList\u306e render\u30e1\u30bd\u30c3\u30c9\u3067ToDo\u306e\u4e00\u884c\u4e00\u884c\u3092\u69cb\u6210\u3059\u308bDataLine\u30af\u30e9\u30b9\u3092\u4f5c\u3063\u3066\u3044\u308b\u3068\u3053\u308d\u3092<br \/>\n\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>[bash]<br \/>\n    render() {<br \/>\n      var dlist = [];<br \/>\n      var i;<\/p>\n<p>      for (i=0; i < this.props.datas.length; i++){\n        var data = this.props.datas[i];\n        dlist.push(<DataLine data={data} key={data.id} \/>);<br \/>\n      }<\/p>\n<p>      return (<\/p>\n<div id=\"dataList\">\n          {dlist}\n        <\/div>\n<p>      );<br \/>\n    }<br \/>\n[\/bash]<\/p>\n<p>\u914d\u5217\u5909\u6570 dlist\u306b DataLine\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092push\u3057\u3066\u3044\u3063\u3066\u307e\u3059\u306d\u3002<br \/>\n\u305d\u3057\u3066\u3001DataLine\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e data\u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u306b DATAS\u306e\uff11\u884c\u306e\u5024<br \/>\n\u3064\u307e\u308aToDo\u4e00\u4ef6\u3092\u30c7\u30fc\u30bf\u3068\u3057\u3066\u6e21\u3057\u3066\u3044\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\nDataLine\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u306f this.props.data\u3067\u3053\u306e\u5024\u3092\u53c2\u7167\u3067\u304d\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\nkey\u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u306b\u3064\u3044\u3066\u3067\u3059\u304c\u3001ReactJS\u3067\u306f\u7e70\u308a\u8fd4\u3057\u30eb\u30fc\u30d7\u3067\u540c\u3058\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u751f\u6210<br \/>\n\u3059\u308b\u3068\u304d\u306f\u3001\uff11\u3064\uff11\u3064\u3092\u30e6\u30cb\u30fc\u30af\u306b\u3059\u308b\u5024\u3092\u30ad\u30fc(key)\u3068\u3057\u3066\u8a2d\u5b9a\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044<br \/>\n\u3068\u3044\u3046\u30eb\u30fc\u30eb\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u3053\u3053\u3067\u306f DATAS\u306e\u4e2d\u306e\u30c7\u30fc\u30bf\u306e id\u3092\u30ad\u30fc\u3068\u3057\u3066\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001ToDo\u306e\uff11\u4ef6\u306b\u3042\u305f\u308bDataLine\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u306a\u306b\u3092\u30ec\u30f3\u30c0\u30fc\u3059\u308b\u3067\u3057\u3087\u3046\u304b\u30fb\u30fb<\/p>\n<p>[bash]<br \/>\n  class DataLine extends React.Component{<br \/>\n    constructor(props){<br \/>\n      super(props);<br \/>\n    }<\/p>\n<p>    render(){<br \/>\n      return (<\/p>\n<div>\n          <button>\u524a\u9664<\/button><br \/>\n          {this.props.data.id} &#8212; {this.props.data.content}\n        <\/div>\n<p>      );<br \/>\n    }<br \/>\n  }<br \/>\n[\/bash]<\/p>\n<p>\u3053\u306e\u3088\u3046\u306bDataLine\u30af\u30e9\u30b9\u306erender\u30e1\u30bd\u30c3\u30c9\u3067\u306f\u30dc\u30bf\u30f3\uff11\u3064\u3068\u3001\u6587\u5b57\u5217\u3068\u3057\u3066\u306e\u30c7\u30fc\u30bf\u306eid\u3068content\u3092\u51fa\u529b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u307e\u3067\u3067\u3001\u3088\u3046\u3084\u304f\u3001ToDoList\u3067\u524a\u9664\u30dc\u30bf\u30f3\u4ed8\u304d\u306e\u4e00\u89a7\u304c\u3067\u304d\u307e\u3057\u305f\u3002<br \/>\n\u3067\u3082\u3001\u3053\u308c\u3058\u3083\u307e\u3060ToDo\u3082\u8ffd\u52a0\u3067\u304d\u306a\u3044\u3057\u3001\u524a\u9664\u3082\u3067\u304d\u306a\u3044\u3002<\/p>\n<p>\u307e\u305a\u306f\u3001\u524a\u9664\u306e\u65b9\u306e\u8aac\u660e\u306b\u5165\u308a\u307e\u3057\u3087\u3046\u3002<br \/>\n\u3067\u3001\u524a\u9664\u3092\u8003\u3048\u308b\u524d\u306b\u3001ReactJS\u3067\u30a2\u30d7\u30ea\u3092\u69cb\u7bc9\u3059\u308b\u4e0a\u3067\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\u3092\u8aac\u660e\u3057\u3066\u304a\u304d\u307e\u3059\u3002<br \/>\n\u30a2\u30d7\u30ea\u306f\u3069\u3093\u306a\u30d1\u30fc\u30c4\u3067\u69cb\u6210\u3055\u308c\u308b\u304b\u30fb\u30fb\u30fb\u3001\u3053\u308c\u306f\u3082\u3046\u8aac\u660e\u6e08\u307f\u3067\u3059\u306d\u3002<br \/>\n\u6b21\u306b\u30a2\u30d7\u30ea\u3067\u52d5\u7684\u306b\u5909\u5316\u3059\u308b\u5024\u3067\u7ba1\u7406\u3057\u3066\u3044\u304b\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3082\u306e\u306f\u4f55\u304b\u30fb\u30fb\u30fb<br \/>\n\u3053\u308c\u3092\u8003\u3048\u306a\u304f\u3066\u306f\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<h4>\n\u52d5\u7684\u306b\u5909\u5316\u3059\u308b\u5024\u3067\u3001\u7ba1\u7406\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3082\u306e\uff1d\u30b9\u30c6\u30fc\u30c8(state\uff09<br \/>\n<\/h4>\n<p>\u306a\u3093\u3067\u3059\u3002<br \/>\n\u305d\u3057\u3066\u3001\u3082\u3046\u3061\u3087\u3063\u3068\u53b3\u5bc6\u306b\u8a00\u3046\u3068\u30fb\u30fb\u30fb\u3001\u4ed6\u306e\u5024\u304b\u3089\u8a08\u7b97\u3057\u305f\u308a\u3057\u3066\u6c42\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u5024\u306f<br \/>\n\u30b9\u30c6\u30fc\u30c8\u3068\u3057\u3066\u306f\u7ba1\u7406\u3057\u307e\u305b\u3093\u3002<br \/>\n\u3069\u3046\u8a08\u7b97\u3057\u3088\u3046\u3068\u3057\u3066\u3082\u3001\u3069\u3053\u304b\u3089\u3082\u5c0e\u304d\u51fa\u305b\u306a\u3044\u5909\u5316\u3059\u308b\u5024\u306e\u307f\u3092\u30b9\u30c6\u30fc\u30c8\u3068\u3057\u3066\u7ba1\u7406\u3057\u307e\u3059\u3002<\/p>\n<p>\u3055\u3066\u3001ToDo\u30ea\u30b9\u30c8\u306b\u304a\u3044\u3066\u30b9\u30c6\u30fc\u30c8\u306f\u306a\u306b\u306b\u306a\u308b\u3067\u3057\u3087\u3046\u304b\u30fb\u30fb\u30fb<\/p>\n<p>\u307e\u305a\u5f53\u7136\u3067\u3059\u304cToDo\u30ea\u30b9\u30c8\u306e\u4e00\u89a7\u30c7\u30fc\u30bf\u3067\u3059\u306d\u3002<br \/>\n\u305d\u3057\u3066\u3082\u3046\u3072\u3068\u3064\u3001ToDo\u30ea\u30b9\u30c8\u306e\uff11\u4ef6\u3092\u5024\u3092\u5165\u529b\u3059\u308b\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306b\u5165\u529b\u3055\u308c\u305f\u5024\u3067\u3059\u3002<br \/>\n\u305d\u3057\u3066\u305d\u3057\u3066\u3001\u6700\u5f8c\u306b\u3082\u3046\u3072\u3068\u3064\u3002ToDo\u30ea\u30b9\u30c8\uff11\u4ef6\uff11\u4ef6\u306f\u30e6\u30cb\u30fc\u30af\u306a\u3082\u306e\u306a\u306e\u3067\u3001<br \/>\nToDo\uff11\u4ef6\u306b\u5bfe\u3057\u3066\uff11\u3064\u306eID\u3092\u6301\u3061\u307e\u3059\u3002\u305d\u306eID\u306f\u91cd\u8907\u3057\u3066\u306f\u3044\u3051\u306a\u3044\u306e\u3067\u3000ID\u306e\u6700\u5927\u5024\u3092<br \/>\n\u30b9\u30c6\u30fc\u30c8\u3068\u3057\u3066\u7ba1\u7406\u3057\u307e\u3059\u3002<\/p>\n<p>\u3067\u3001\u307e\u305f\u307e\u305f\u3053\u3053\u3082\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\u306a\u306e\u3067\u3059\u304c\u30fb\u30fb\u30fb<br \/>\n\u30b9\u30c6\u30fc\u30c8\u3092\u8ab0\u304c\u3001\u3064\u307e\u308a\u3069\u306e\u30af\u30e9\u30b9\u304c\u7ba1\u7406\u3059\u308b\u304b\u3068\u3044\u3046\u3053\u3068\u306a\u306e\u3067\u3059\u304c\u30fb\u30fb<\/p>\n<h4>\u4e00\u756a\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306b\u3042\u308b\u30af\u30e9\u30b9\u304c\u30b9\u30c6\u30fc\u30c8\u3092\u7ba1\u7406\u3059\u308b<\/h4>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<br \/>\n\u53b3\u5bc6\u306b\u8a00\u3046\u3068\u3001\u672c\u5f53\u306f\u3053\u308c\u306f\u5618\u3060\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u6163\u308c\u306a\u3044\u3046\u3061\u306f<br \/>\n\u4e00\u756a\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u30af\u30e9\u30b9\u306b\u7ba1\u7406\u3055\u305b\u308b\u306e\u304c\u826f\u3044\u3067\u3057\u3087\u3046\u3002<br \/>\n\u3064\u307e\u308a\u4eca\u56de\u306eToDo\u30ea\u30b9\u30c8\u3067\u8a00\u3046\u3068\u3000ToDoList\u30af\u30e9\u30b9\u306b\u7ba1\u7406\u3055\u305b\u307e\u3059\u3002<\/p>\n<p>[bash]<br \/>\n  class ToDoList extends React.Component{<br \/>\n    constructor(props){<br \/>\n      super(props);<br \/>\n      var maxId = 0;<br \/>\n      props.datas.forEach(function(data){<br \/>\n          if (data.id > maxId){<br \/>\n            maxId = data.id;<br \/>\n          }<br \/>\n      });<\/p>\n<p>      this.state = {<br \/>\n        datas: props.datas,<br \/>\n        maxId: maxId,<br \/>\n        content: &#8221;<br \/>\n      }<br \/>\n    }<br \/>\n[\/bash]<\/p>\n<p>\u3088\u3063\u3066 ToDoList\u30af\u30e9\u30b9\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f\u4e0a\u8a18\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\uff08\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3067\u306f\u30b9\u30c6\u30fc\u30c8\u3067\u7ba1\u7406\u3059\u308b\u5024\u306e\u521d\u671f\u5024\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002\uff09<\/p>\n<h4>this.state = \uff5b\u30b9\u30c6\u30fc\u30c8\u3067\u7ba1\u7406\u3059\u308b\u5909\u6570\u7fa4\uff5d<\/h4>\n<p>\u305d\u3057\u3066\u3001 this.state = \u3068\u8a18\u8ff0\u3057\u3066\u3001\u30b9\u30c6\u30fc\u30c8\u306e\u5024\u3092\u8a2d\u5b9a\u3067\u304d\u308b\u306e\u306f\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3060\u3051\u3060\u3068\u7406\u89e3\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>ReactJS\u3067\u306f\u3001\u30b9\u30c6\u30fc\u30c8\u306e\u5024\u304c\u5909\u5316\u3059\u308b\u3068\u5fc5\u8981\u306a\u3068\u3053\u308d\u3060\u3051\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3092\u81ea\u52d5\u3067\u884c\u3044\u307e\u3059\u3002<br \/>\n\u30b9\u30c6\u30fc\u30c8\u3092\u5909\u5316\u3055\u305b\u308b\u3002\u3064\u307e\u308a\u30b9\u30c6\u30fc\u30c8\u306e\u5024\u3092\u30bb\u30c3\u30c8\u3057\u3066\u81ea\u52d5\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3059\u308b\u306b\u306f<br \/>\n\u30af\u30e9\u30b9\u306e\u3000setState\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3044\u307e\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u3001ToDo\u30ea\u30b9\u30c8\u306e\u6700\u5927ID(maxId)\u3092\u5909\u5316\u3055\u305b\u3088\u3046\u3068\u3059\u308b\u306a\u3089\u3070<br \/>\n\u30b9\u30c6\u30fc\u30c8\u3092\u7ba1\u7406\u3059\u308b\u30af\u30e9\u30b9\u3067\u3042\u308bToDoList\u30af\u30e9\u30b9\u306e\u30e1\u30bd\u30c3\u30c9\u306e\u4e2d\u3067<\/p>\n<p>[bash]<br \/>\nthis.setState({maxId: xxxx});<br \/>\n[\/bash]<\/p>\n<p>\u3068\u8a18\u8ff0\u3057\u3066\u3084\u308a\u307e\u3059\u3002<br \/>\nID\u306e\u6700\u5927\u5024\u3092\u5909\u3048\u3066\u3082\u3001\u753b\u9762\u4e0a\u5909\u5316\u3059\u308b\u5fc5\u8981\u306e\u3042\u308b\u3068\u3053\u308d\u306f\u306a\u3044\u306e\u3067ReactJS\u306f<br \/>\n\u30b9\u30c6\u30fc\u30c8\u306e\u5024\u306e\u307f\u3092\u5909\u5316\u3055\u305b\u3001\u306a\u306b\u3082\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u306f\u884c\u3044\u307e\u305b\u3093\u3002<\/p>\n<p>ToDo\u30ea\u30b9\u30c8\u304b\u3089\u30c7\u30fc\u30bf\u3092\u524a\u9664\u3059\u308b\u3053\u3068\u3092\u8003\u3048\u308b\u3068\u30fb\u30fb\u30fb<br \/>\nToDoList\u30af\u30e9\u30b9\u5185\u306e\u4f55\u3089\u304b\u306e\u30e1\u30bd\u30c3\u30c9\u3067<\/p>\n<p>[bash]<br \/>\nvar newDatas = [];<br \/>\nvar i;<\/p>\n<p>for (i = 0 ; i &lt; this.state.datas.length ; i++){<br \/>\n  var data = this.state.datas[i];<br \/>\n  if (data.id != \u524a\u9664\u3059\u308bID){<br \/>\n     newDatas.push(data);<br \/>\n  }<br \/>\n}<\/p>\n<p>this.setState({datas: newDatas});<br \/>\n[\/bash]<\/p>\n<p>\u3068\u3057\u3066\u3084\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\nReactJS\u304c\u7ba1\u7406\u3059\u308b datas\u30b9\u30c6\u30fc\u30c8\u304c\u5909\u5316\u3059\u308b\u3068\u3001\u305d\u306e\u5909\u6570\u306e\u5024\u3092\u4f7f\u3063\u3066<br \/>\n\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3055\u308c\u3066\u3044\u308b\u90e8\u5206\u304c\u81ea\u52d5\u7684\u306b\u8abf\u6574\u3055\u308c\u308b\u306e\u3067\u3059\u3002<br \/>\n\u4f8b\u3048\u3070 jQuery\u306a\u3093\u304b\u3067\u540c\u3058\u3088\u3046\u306a\u3053\u3068\u3092\u3057\u3088\u3046\u3068\u601d\u3048\u3070\u3001<br \/>\nToDo\u30ea\u30b9\u30c8\u306e\u4e00\u89a7\u306e\u30bf\u30b0\u306e\u5b50\u4f9b\u3092\uff08ToDo\uff11\u4ef6\uff09\u30eb\u30fc\u30d7\u3055\u305b\u306a\u304c\u3089<br \/>\n\u4e0d\u8981\u306a\u884c\u306eHTML\u30bf\u30b0\u3092 remove\u3059\u308b\u306a\u3069\u3067\u3059\u306d\u3002<\/p>\n<p>\u3067\u306f\u6b21\u306b\u30da\u30fc\u30b8\u4e0a\u3067\u8d77\u3053\u308b\u30a4\u30d9\u30f3\u30c8\u306f\u3069\u306e\u3088\u3046\u306b\u3057\u3066\u6271\u3046\u306e\u3067\u3057\u3087\u3046\u304b\uff1f<br \/>\n\u307e\u305a\u3001ToDo\u4e00\u4ef6\u3092\u524a\u9664\u3059\u308b\u51e6\u7406\u3001\u3064\u307e\u308aToDo\u30ea\u30b9\u30c8\u306e\u5de6\u5074\u306b\u8868\u793a\u3055\u308c\u3066\u3044\u308b<br \/>\n\u300c\u524a\u9664\u30dc\u30bf\u30f3\u300d\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u51e6\u7406\u3092\u3069\u3053\u306b\u8a18\u8ff0\u3057\u3066\u3001\u30af\u30ea\u30c3\u30af\u306b\u3088\u3063\u3066<br \/>\n\u30b9\u30c6\u30fc\u30c8\u306e\u5024\u3092\u5909\u5316\u3055\u305b\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u300c\u524a\u9664\u30dc\u30bf\u30f3\u300d\u306fDataLine\u30af\u30e9\u30b9\u5185\u3067\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001<br \/>\n\u5f53\u7136\u30af\u30ea\u30c3\u30af\u30a4\u30d9\u30f3\u30c8\u306e\u51e6\u7406\u306fDataLine\u30af\u30e9\u30b9\u5185\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<p>\u3069\u3046\u66f8\u304f\u304b\u3068\u3044\u3046\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>[bash]<br \/>\n  class DataLine extends React.Component{<br \/>\n    constructor(props){<br \/>\n      super(props);<br \/>\n    }<\/p>\n<p>    handleClick(event){<br \/>\n      this.props.onDelete(this.props.data.id);<br \/>\n    }<\/p>\n<p>    render(){<br \/>\n      return (<\/p>\n<div>\n          <button onClick={() => this.handleClick()}>\u524a\u9664<\/button><br \/>\n          {this.props.data.id} &#8212; {this.props.data.content}\n        <\/div>\n<p>      );<br \/>\n    }<br \/>\n  }<br \/>\n[\/bash]<\/p>\n<p>\u3053\u3053\u306f\u7d50\u69cb\u666e\u901a\u306a\u306e\u3067\u3059\u304c\u3001\u524a\u9664\u30dc\u30bf\u30f3\u3092\u30ec\u30f3\u30c0\u30fc\u3057\u3066\u3044\u308b\u90e8\u5206\u3067<br \/>\nonClick\u30a4\u30d9\u30f3\u30c8\u3092\u5b9a\u7fa9\u3057\u3066\u3084\u308a\u307e\u3059\u3002<br \/>\nReactJS\u3067\u306f <strong>onclick<\/strong>\u3067\u306f\u306a\u304f\u3001<strong>onClick<\/strong>\u3067\u3059\u3002<br \/>\n\u305d\u3057\u3066onClick\u3092\u51e6\u7406\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u306f\u81ea\u5206\u306e\u30af\u30e9\u30b9\u5185\u306e handleClick\u30e1\u30bd\u30c3\u30c9\u3068\u3057\u307e\u3059\u3002<\/p>\n<p>\u3067\u3001handelClick\u30e1\u30bd\u30c3\u30c9\u5185\u306e\u8a18\u8ff0\u3092\u898b\u3066\u307f\u308b\u3068<\/p>\n<p>[bash]<br \/>\n    handleClick(event){<br \/>\n      this.props.onDelete(this.props.data.id);<br \/>\n    }<br \/>\n[\/bash]<\/p>\n<p>\u3068\u306a\u3063\u3066\u3044\u3066\u3001ToDo\u30ea\u30b9\u30c8\u306edatas\u3000\u3092\u524a\u9664\u3057\u3066\u3044\u307e\u305b\u3093\u306d\u3002<br \/>\n\u306a\u305c\u304b\u3068\u3044\u3046\u3068\u3001\u4eca\u56de\u7ba1\u7406\u3059\u308b\u30b9\u30c6\u30fc\u30c8\u306f\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u30af\u30e9\u30b9ToDoList\u30af\u30e9\u30b9\u3067\u7ba1\u7406\u3057\u3066\u3044\u308b\u304b\u3089\u30fb\u30fb<br \/>\n\u305d\u306e\u5909\u6570\u3092\u524a\u9664\u3057\u3088\u3046\u306b\u3082\u3001\u524a\u9664\u3067\u304d\u306a\u3044\u306e\u3067\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u3069\u3046\u3059\u308b\u304b\u30fb\u30fb\u30fb<\/p>\n<h4>\u81ea\u5206\u3067\u30b9\u30c6\u30fc\u30c8\u3092\u51e6\u7406\u3067\u304d\u306a\u3044\u306a\u3089\u3001\u4e0a\u4f4d\u306e\u30af\u30e9\u30b9\u306b\u304a\u9858\u3044\u3059\u308c\u3070\u826f\u3044<\/h4>\n<p>[bash]<br \/>\nthis.props.onDelete(this.props.data.id);<br \/>\n[\/bash] <\/p>\n<p>\u3053\u308c\u306f\u3001\u81ea\u5206\u306e\u30af\u30e9\u30b9\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306b onDelete\u3068\u3044\u3046\u306e\u3092\u4f5c\u308b\u3068\u3044\u3046\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002<br \/>\n\u305d\u3057\u3066\u305d\u308c\u306f\u5909\u6570\u3092\u7ba1\u7406\u3059\u308b\u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u306f\u306a\u304f\u3066\u3001\u30a4\u30d9\u30f3\u30c8\u3092\u51e6\u7406\u3059\u308b\u30d7\u30ed\u30d1\u30c6\u30a3\u3060\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<br \/>\n\u96e3\u3057\u3044\u3067\u3059\u306d\u3002\u304b\u306a\u308a\u9811\u5f35\u3063\u3066\u7406\u89e3\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>DataLine\u30af\u30e9\u30b9\u306eonDelete\u30d7\u30ed\u30d1\u30c6\u30a3\u306f\u30a4\u30d9\u30f3\u30c8\u3092\u51e6\u7406\u3059\u308b\u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u3042\u308b\u3002<br \/>\n\u3067\u30fb\u30fb\u3053\u306e\u30a4\u30d9\u30f3\u30c8\u3092DataLine\u30af\u30e9\u30b9\u3088\u308a\u4e0a\u4f4d\u306e\u30af\u30e9\u30b9\u3067\u51e6\u7406\u3059\u308b\u306b\u306f\u3069\u3046\u3059\u308b\u304b\u3068\u3044\u3046\u3068<br \/>\nDataLine\u3092\u30ec\u30f3\u30c0\u30fc\u3059\u308b\u90e8\u5206\u306b\u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u3068\u3057\u3066\u3001\u4e0a\u4f4d\u30af\u30e9\u30b9\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u5b9a\u7fa9\u3057\u3066\u3084\u308c\u3070\u826f\u3044\u3002<br \/>\n\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u5177\u4f53\u7684\u306b\u306f<\/p>\n<p>[bash]<br \/>\nclass \u4e0a\u4f4d\u30af\u30e9\u30b9 extends React.Component{<\/p>\n<p>  handleDelete(id){<br \/>\n    \u30b9\u30c6\u30fc\u30c8\u3092\u306a\u3093\u3068\u304b\u524a\u9664\u3057\u3088\u3046\u3068\u52aa\u529b\u3059\u308b\u3002<br \/>\n  }<\/p>\n<p>  render(){<\/p>\n<div>\n        <DataLine onDelete={(id) = this.handleDelete(id)} \/>\n     <\/div>\n<p>  }<br \/>\n}<br \/>\n[\/bash]<\/p>\n<p>\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u3067\u3001\u4eca\u56de\u306e\u4f8b\u3067\u8a00\u3046\u3068\u3001DataLine\u306e\uff11\u3064\u4e0a\u4f4d\u306e\u30af\u30e9\u30b9\u306f DataList\u30af\u30e9\u30b9\u306a\u306e\u3067\u30fb\u30fb\u30fb<br \/>\n\u30c7\u30fc\u30bf\u4e00\u89a7\u306e\u30b9\u30c6\u30fc\u30c8\u5909\u6570\u3092\u53c2\u7167\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>\u51fa\u6765\u306a\u3044\uff1f\uff1f\uff1f\uff1f<\/p>\n<p>\u3068\u601d\u3046\u65b9\u3082\u3044\u3089\u3063\u3057\u3083\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<br \/>\nDataList\u306f\u30c7\u30fc\u30bf\u306e\u4e00\u89a7\u3092\u51fa\u529b\u3057\u3066\u308b\u3093\u3060\u304b\u3089\u3001\u5909\u6570\u306e\u5024\u3092\u524a\u9664\u3067\u304d\u308b\u3058\u3083\u3093\u3002<br \/>\n\u305d\u3046\u601d\u3046\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u306d\u3002<\/p>\n<p>\u3067\u3082 ReactJS\u306e\u9244\u5247<\/p>\n<h4>\u30b9\u30c6\u30fc\u30c8\u306f\u6700\u4e0a\u4f4d\u306e\u30af\u30e9\u30b9\u3067\u7ba1\u7406\u3059\u308b<\/h4>\n<p>DataList\u306f\u6700\u4e0a\u4f4d\u3058\u3083\u3042\u308a\u307e\u305b\u3093\u306d\u3002\u3064\u307e\u308a\u30b9\u30c6\u30fc\u30c8\u3092\u7ba1\u7406\u3057\u3066\u3044\u306a\u3044\u3002<br \/>\n\u306a\u306e\u3067\u3001\u524a\u9664\u3057\u3088\u3046\u306b\u3082\u524a\u9664\u3067\u304d\u307e\u305b\u3093\u3002<br \/>\n\u4e00\u89a7\u30c7\u30fc\u30bf\u306f\u30b9\u30c6\u30fc\u30c8(state)\u3067\u306f\u306a\u304f\u3001\u30d7\u30ed\u30d1\u30c6\u30a3(props)\u3067\u53c2\u7167\u3067\u304d\u308b\u306e\u307f\u3067\u3059\u3002<\/p>\n<p>\u3058\u3083\u3042\u56f0\u3063\u305f\u30fb\u30fb\u30fb\u3000\u3069\u3046\u3059\u308a\u3083\u3044\u3044\u3093\u3060\u3068\u306a\u308a\u307e\u3059\u304c\u30fb\u30fb\u30fb<\/p>\n<h4>\u81ea\u5206\u306e\u30af\u30e9\u30b9\u3067\u30b9\u30c6\u30fc\u30c8\u3092\u5909\u5316\u3055\u305b\u308b\u3053\u3068\u304c\u51fa\u6765\u306a\u3044\u306a\u3089\u3001\u4e0a\u4f4d\u306b\u4f1d\u3048\u308a\u3083\u3044\u3044<\/h4>\n<p>\u3067\u3001\u4f1d\u3048\u308b\u65b9\u6cd5\u3067\u3059\u304c\u3001\u3053\u308c\u306fDataLine\u30af\u30e9\u30b9\u306e onDelete\u30d7\u30ed\u30d1\u30c6\u30a3\u3068\u540c\u3058\u3067\u3001<br \/>\nDataList\u30af\u30e9\u30b9\u306b\u3082 onDelete\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f5c\u308a\u3001\u305d\u3053\u3092\u7d4c\u7531\u3057\u3066\u3001\u6700\u4e0a\u4f4d\u306e<br \/>\nToDoList\u30af\u30e9\u30b9\u306b\u60c5\u5831\u3092\u4f1d\u3048\u308a\u3083\u3044\u3044\u3001\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u5148\u307b\u3069\u306e\u90e8\u5206\u3092\u66f8\u304d\u63db\u3048\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>[bash]<br \/>\nclass \u4e0a\u4f4d\u30af\u30e9\u30b9 extends React.Component{<\/p>\n<p>  handleDelete(id){<br \/>\n    \/\/\u30b9\u30c6\u30fc\u30c8\u3092\u76f4\u63a5\u524a\u9664\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u4e0a\u4f4d\u306b\u4f1d\u3048\u308b\u3002<br \/>\n    this.props.onDelete(id);<br \/>\n  }<\/p>\n<p>  render(){<\/p>\n<div>\n        <DataLine onDelete={(id) = this.handleDelete(id)} \/>\n     <\/div>\n<p>  }<br \/>\n}<br \/>\n[\/bash]<\/p>\n<p>\u3067\u3001DataList\u30af\u30e9\u30b9\u306e\u4e0a\u4f4d\u30af\u30e9\u30b9\u306f ToDoList\u30af\u30e9\u30b9\u306a\u306e\u3067\u3001<br \/>\nToDoList\u30af\u30e9\u30b9\u306e render\u30e1\u30bd\u30c3\u30c9\u3067 DataList\u30af\u30e9\u30b9\u3092\u30ec\u30f3\u30c0\u30fc\u3059\u308b\u969b\u306b<br \/>\nonDelete\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u5024\u3092 ToDoList\u30af\u30e9\u30b9\u5185\u306e\u30e1\u30bd\u30c3\u30c9\u3078\u8ee2\u9001\u3057\u3066\u3084\u308c\u3070\u826f\u3044\u3002<\/p>\n<p>\u5177\u4f53\u7684\u306b\u306f\u3001<\/p>\n<p>[bash]<br \/>\n  class ToDoList extends React.Component{<\/p>\n<p>    handleOnDelete(delid){<br \/>\n      var datas = this.state.datas.slice();<br \/>\n      var newDatas = [];<br \/>\n      datas.forEach(function(data){<br \/>\n        if (data.id != delid){<br \/>\n          newDatas.push(data);<br \/>\n        }<br \/>\n      });<\/p>\n<p>      this.setState({datas: newDatas});<\/p>\n<p>    }<\/p>\n<p>    render(){<br \/>\n      return (<\/p>\n<div id=\"toDoList\">\n          <NewToDo \/><br \/>\n          <DataList datas={this.state.datas} onDelete={(id) => this.handleOnDelete(id)}\/>\n        <\/div>\n<p>      );<br \/>\n    }<br \/>\n  }<br \/>\n[\/bash]<\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u3066\u3084\u308a\u307e\u3059\u3002<br \/>\n\u306a\u306b\u3092\u3057\u3066\u3044\u308b\u304b\u3068\u3044\u3046\u3068\u3001\u3000DataList\u30af\u30e9\u30b9\u5185\u3067\u8d77\u3053\u3063\u305f\u3000onDelete\u30a4\u30d9\u30f3\u30c8\u306f<br \/>\n\u81ea\u5206\u306e\u30af\u30e9\u30b9\u5185\u306e\u30e1\u30bd\u30c3\u30c9 handleOnDelete\u3067\u51e6\u7406\u3059\u308b\u3088\u3002\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>ToDoList\u30af\u30e9\u30b9\u306ehandleOnDelete\u3067\u306f\u3001\u3088\u3046\u3084\u304f ToDo\u4e00\u89a7\u306e\u30b9\u30c6\u30fc\u30c8\u3092\u53c2\u7167\u3059\u308b\u3053\u3068\u304c<br \/>\n\u3067\u304d\u308b\u306e\u3067\u3001\u3044\u3088\u3044\u3088\u3053\u3053\u3067\u30b9\u30c6\u30fc\u30c8\u306e\u5024\u3092\u5909\u5316\u3055\u305b\u307e\u3059\u3002<\/p>\n<p>handleOnDelete\u30e1\u30bd\u30c3\u30c9\u306e\u4e2d\u3092\u898b\u3066\u3044\u305f\u3060\u304f\u3068\u30fb\u30fb\u30fb<br \/>\nstate.datas\u3000\u3092\u30eb\u30fc\u30d7\u3055\u305b\u306a\u304c\u3089\u3001\u305d\u306e\u30c7\u30fc\u30bf\u306eid\u304c\u30e1\u30bd\u30c3\u30c9\u306e\u5f15\u6570\u3068\u3057\u3066\u6e21\u3063\u3066\u304d\u305f\u3002<br \/>\n\u524a\u9664\u5bfe\u8c61ID\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u3001\u5bfe\u8c61\u5916\u306a\u3089\u65b0\u305f\u306a\u914d\u5217\u5909\u6570\u306bpush\u3059\u308b\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u5168\u30c7\u30fc\u30bf\u306e\u30eb\u30fc\u30d7\u304c\u7d42\u308f\u3063\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067<\/p>\n<p>[bash]<br \/>\n      this.setState({datas: newDatas});<br \/>\n[\/bash]<\/p>\n<p>\u3068\u3057\u3066\u3001\u30b9\u30c6\u30fc\u30c8\u306e\u5909\u66f4\u3092ReactJS\u306b\u901a\u77e5\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u9577\u304b\u3063\u305f\u3067\u3059\u306d\u3002\u7406\u89e3\u3067\u304d\u307e\u3057\u305f\u304b\uff1f\uff1f<\/p>\n<p>\u3067\u306f\u6b21\u884c\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\n\u3044\u3088\u3044\u3088ToDo\u306e\u8ffd\u52a0\u3067\u3059\u3002<\/p>\n<p>\u8ffd\u52a0\u306f NewToDo\u30af\u30e9\u30b9\u3067\u884c\u3044\u307e\u3059\u3002<\/p>\n<p>[bash]<br \/>\n  class NewToDo extends React.Component{<br \/>\n    constructor(props){<br \/>\n      super(props);<br \/>\n    }<\/p>\n<p>    handleClick(){<br \/>\n      this.props.onAdd();<br \/>\n    }<\/p>\n<p>    handleChange(event){<br \/>\n      var val = event.target.value;<br \/>\n      this.props.onContentChange(val);<br \/>\n    }<\/p>\n<p>    render(){<br \/>\n      return (<\/p>\n<div id=\"newToDo\">\n          <label>\u30b3\u30f3\u30c6\u30f3\u30c4<\/label><br \/>\n          <input type=\"text\" name=\"content\"\n           value={this.props.content}\n           onChange={(e) => this.handleChange(e)}\/><br \/>\n          <button onClick={()=> this.handleClick()}><br \/>\n            \u8ffd\u52a0<br \/>\n          <\/button>\n        <\/div>\n<p>      );<br \/>\n    }<br \/>\n  }<br \/>\n[\/bash]<\/p>\n<p>\u3044\u304d\u306a\u308a\u30bd\u30fc\u30b9\u5168\u90e8\u8cbc\u308a\u4ed8\u3051\u305f\u306e\u3067 \u304e\u3087\u3063\u3068\u3055\u308c\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u30fb\u30fb\u30fb<br \/>\n\u3053\u3053\u307e\u3067\u306e\u3053\u3068\u304c\u7406\u89e3\u3067\u304d\u3066\u3044\u305f\u3089\u306a\u3093\u3068\u304b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u307e\u305a\u306f render\u30e1\u30bd\u30c3\u30c9\u304b\u3089\u8aac\u660e\u3002<\/p>\n<p>div\u30bf\u30b0\u306e\u4e2d\u306blabel\uff11\u3064\u3068\u3001input\uff11\u3064\u3068button\uff11\u3064\u3092\u30ec\u30f3\u30c0\u30fc\u3057\u3066\u307e\u3059\u3002<br \/>\nlabel\u306f\u5358\u306a\u308b\u76ee\u5370\u306a\u306e\u3067\u8aac\u660e\u306f\u7701\u7565\u3059\u308b\u3068\u3057\u3066\u30fb\u30fb\u30fb<\/p>\n<p>input \u306fToDo\u306e\u4e2d\u8eab\u3092\u8a18\u8ff0\u3059\u308b\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u3067\u3059\u3002<br \/>\nbutton \u306fToDo\u3092\u8ffd\u52a0\u3059\u308b\u305f\u3081\u306e\u30dc\u30bf\u30f3\u3067\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u3053\u3053\u3067\u6539\u3081\u3066ToDoList\u5168\u4f53\u304c\u7ba1\u7406\u3059\u308b\u30b9\u30c6\u30fc\u30c8\u304c\u4f55\u3060\u3063\u305f\u304b\u601d\u3044\u51fa\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<ul>\n<li>ToDo\u30ea\u30b9\u30c8\u306e\u4e00\u89a7\u30c7\u30fc\u30bf<\/li>\n<li>ToDo\u30ea\u30b9\u30c8\u306e\uff11\u4ef6\u3092\u5024\u3092\u5165\u529b\u3059\u308b\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306b\u5165\u529b\u3055\u308c\u305f\u5024<\/li>\n<li>\u30c7\u30fc\u30bf\u306eID\u306e\u6700\u5927\u5024<\/li>\n<\/ul>\n<p>\u305d\u3057\u3066\u3053\u308c\u3089\u306e\u30c7\u30fc\u30bf\u306f\u3059\u3079\u3066\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u30af\u30e9\u30b9 ToDoList\u3067\u7ba1\u7406\u3055\u308c\u308b\u306e\u3067\u3057\u305f\u3002<br \/>\n\u3064\u307e\u308aNewToDo\u30af\u30e9\u30b9\u306e input \u306b\u5165\u529b\u3055\u308c\u305f\u5024\u306f\u3001NewToDo\u30af\u30e9\u30b9\u3067\u7ba1\u7406\u3059\u308b\u306e\u3067\u306f\u306a\u304f<br \/>\n\u4e0a\u4f4d\u306eToDoList\u30af\u30e9\u30b9\u306b\u7ba1\u7406\u3092\u4efb\u305b\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002<br \/>\n\u305d\u3057\u3066\u3001NewToDo\u30af\u30e9\u30b9\u306ebutton\u30af\u30ea\u30c3\u30af\u3067ToDo\u30ea\u30b9\u30c8\u306b\u8ffd\u52a0\u3057\u305f\u3044\u304c\u3001\u3053\u308c\u3082<br \/>\n\u4e0a\u4f4d\u306eToDoList\u30af\u30e9\u30b9\u306b\u30dc\u30bf\u30f3\u304c\u62bc\u3055\u308c\u305f\u3053\u3068\u3092\u901a\u77e5\u3057\u3066\u3001\u51e6\u7406\u3092\u4efb\u305b\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002<\/p>\n<p>\u3053\u306e\u3053\u3068\u304c<\/p>\n<p>[bash]<br \/>\n          <input type=\"text\" name=\"content\"\n           value={this.props.content}\n           onChange={(e) => this.handleChange(e)}\/><br \/>\n          <button onClick={()=> this.handleClick()}><br \/>\n            \u8ffd\u52a0<br \/>\n          <\/button><br \/>\n[\/bash]<\/p>\n<p>input\u3067\u306f onChange \u3064\u307e\u308a\u5024\u304c\uff11\u6587\u5b57\u3067\u3082\u5909\u5316\u3059\u308b\u305f\u3073\u306b\u3001\u89aa\u30af\u30e9\u30b9\u3067\u3042\u308bToDoList\u306b<br \/>\n\u30a4\u30d9\u30f3\u30c8\u3092\u7d4c\u7531\u3057\u3066\u30b9\u30c6\u30fc\u30c8\u306e\u5909\u5316\u3092\u4f1d\u3048\u3066\u3044\u308b\u3002<br \/>\n\u30dc\u30bf\u30f3\u306e\u30af\u30ea\u30c3\u30af\u306f click\u3057\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u89aa\u30af\u30e9\u30b9\u3067\u3042\u308bToDoList\u306b<br \/>\n\u30a4\u30d9\u30f3\u30c8\u3092\u7d4c\u7531\u3057\u3066\u30b9\u30c6\u30fc\u30c8\u306e\u5909\u5316\u3092\u4f1d\u3048\u3066\u3044\u308b\u3002<\/p>\n<p>\u3053\u308c\u3060\u3051\u3067\u3059\u3002NewToDo\u30af\u30e9\u30b9\u306f\u81ea\u5206\u3067\u3059\u308b\u3053\u3068\u306f\u3001\u307b\u3068\u3093\u3069\u306a\u306b\u3082\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n\u5909\u5316\uff08\u30a4\u30d9\u30f3\u30c8\uff09\u304c\u3042\u3063\u305f\u3053\u3068\u3092\u89aa\u30af\u30e9\u30b9\u3078\u901a\u77e5\u3057\u3066\u3044\u308b\u306e\u307f\u3067\u3059\u3002<\/p>\n<p>\u3067\u306f\u6700\u5f8c\u3001\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e ToDoList\u30af\u30e9\u30b9\u3092\u8997\u3044\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>[bash]<br \/>\n  class ToDoList extends React.Component{<br \/>\n    constructor(props){<br \/>\n      super(props);<br \/>\n      var maxId = 0;<br \/>\n      props.datas.forEach(function(data){<br \/>\n          if (data.id > maxId){<br \/>\n            maxId = data.id;<br \/>\n          }<br \/>\n      });<\/p>\n<p>      this.state = {<br \/>\n        datas: props.datas,<br \/>\n        maxId: maxId,<br \/>\n        content: &#8221;<br \/>\n      }<br \/>\n    }<\/p>\n<p>    handleContentChange(ct){<br \/>\n      this.setState({content: ct});<br \/>\n    }<\/p>\n<p>    handleOnAdd(){<br \/>\n      var maxId = this.state.maxId + 1;<br \/>\n      var datas = this.state.datas.slice();<br \/>\n      datas.push({id: maxId, content: this.state.content});<\/p>\n<p>      this.setState({maxId: maxId, content: &#8221;, datas: datas});<br \/>\n    }<\/p>\n<p>    handleOnDelete(delid){<br \/>\n      var datas = this.state.datas.slice();<br \/>\n      var newDatas = [];<br \/>\n      datas.forEach(function(data){<br \/>\n        if (data.id != delid){<br \/>\n          newDatas.push(data);<br \/>\n        }<br \/>\n      });<\/p>\n<p>      this.setState({datas: newDatas});<\/p>\n<p>    }<\/p>\n<p>    render(){<br \/>\n      return (<\/p>\n<div id=\"toDoList\">\n          <NewToDo\n            content={this.state.content}\n            onAdd={() => this.handleOnAdd()}<br \/>\n            onContentChange={(ct) => this.handleContentChange(ct)}<br \/>\n            \/><br \/>\n          <DataList datas={this.state.datas} onDelete={(id) => this.handleOnDelete(id)}\/>\n        <\/div>\n<p>      );<br \/>\n    }<br \/>\n  }<br \/>\n[\/bash]<\/p>\n<p>\u307e\u305a\u6ce8\u76ee\u3057\u3066\u3044\u305f\u3060\u304d\u305f\u3044\u306e\u306f render\u30e1\u30bd\u30c3\u30c9\u3002<\/p>\n<ul>\n<li>NewToDo\u30af\u30e9\u30b9\u306e\u30ec\u30f3\u30c0\u30fc<\/li>\n<li>DataList\u30af\u30e9\u30b9\u306e\u30ec\u30f3\u30c0\u30fc<\/li>\n<\/ul>\n<p>NewToDo\u30af\u30e9\u30b9\u306e onAdd\u30d7\u30ed\u30d1\u30c6\u30a3\uff08\u30a4\u30d9\u30f3\u30c8\uff09\u306b\u81ea\u5206\u306e\u30af\u30e9\u30b9\u306e handleOnAdd\u30e1\u30bd\u30c3\u30c9\u3078\u306e\u8ee2\u9001\u3092\u8a2d\u5b9a\u3002<br \/>\nonContentChange\u30d7\u30ed\u30d1\u30c6\u30a3\uff08\u30a4\u30d9\u30f3\u30c8\uff09\u306b\u81ea\u5206\u306e\u30af\u30e9\u30b9\u306e handleContentChange\u30e1\u30bd\u30c3\u30c9\u3078\u306e\u8ee2\u9001\u3092\u8a2d\u5b9a\u3002<\/p>\n<p>DataList\u30af\u30e9\u30b9\u306eonDelete\u30d7\u30ed\u30d1\u30c6\u30a3\uff08\u30a4\u30d9\u30f3\u30c8\uff09\u306b\u81ea\u5206\u306e\u30af\u30e9\u30b9\u306e handleOnDelete\u30e1\u30bd\u30c3\u30c9\u3078\u306e\u8ee2\u9001\u3092\u8a2d\u5b9a\u3002<\/p>\n<p>DataList\u30af\u30e9\u30b9\u306eonDelete\u306e\u65b9\u306f\u3059\u3067\u306b\u8aac\u660e\u6e08\u307f\u306a\u306e\u3067\u3001NewToDo\u30af\u30e9\u30b9\u306e\u65b9\u306e\u8aac\u660e\u3092\u3057\u307e\u3059\u3002<\/p>\n<p>[bash]<br \/>\n    handleContentChange(ct){<br \/>\n      this.setState({content: ct});<br \/>\n    }<br \/>\n[\/bash]<\/p>\n<p>NewToDo\u30af\u30e9\u30b9\u306e input\uff08\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\uff09\u3067\u8d77\u3053\u3063\u305f\u5024\u306e\u5909\u5316\u3092\u30a4\u30d9\u30f3\u30c8\u7d4c\u7531\u3067\u901a\u77e5\u3057\u3066\u3082\u3089\u3063\u3066<br \/>\nsetState\u30e1\u30bd\u30c3\u30c9\u3067 \u30b9\u30c6\u30fc\u30c8\u3092\u5909\u66f4\u3002<\/p>\n<p>[bash]<br \/>\n    handleOnAdd(){<br \/>\n      var maxId = this.state.maxId + 1;<br \/>\n      var datas = this.state.datas.slice();<br \/>\n      datas.push({id: maxId, content: this.state.content});<\/p>\n<p>      this.setState({maxId: maxId, content: &#8221;, datas: datas});<br \/>\n    }<br \/>\n[\/bash]<\/p>\n<p>NewToDo\u30af\u30e9\u30b9\u306e\u30dc\u30bf\u30f3\u30af\u30ea\u30c3\u30af\u3092\u30a4\u30d9\u30f3\u30c8\u7d4c\u7531\u3067\u901a\u77e5\u3057\u3066\u3082\u3089\u3063\u3066\u3001<br \/>\n\u6700\u5927\u5024\u3092\uff11\u52a0\u7b97\u3057\u3066\u3001ToDo\u30c7\u30fc\u30bf\u306e\u6700\u5f8c\u5c3e\u306b\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0(push)\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001setState\u3067\u3000maxId\u3068content\u3068datas \u306e\u5909\u66f4\u3092\u4f1d\u3048<br \/>\nReactJS\u306b\u30ec\u30f3\u30c0\u30fc\u3092\u4f9d\u983c\u3057\u307e\u3059\u3002<\/p>\n<p>\u9577\u304b\u3063\u305f\u3067\u3059\u306d\u3002\u3088\u3046\u3084\u304fToDo\u30ea\u30b9\u30c8\u306e\u5b8c\u6210\u3067\u3059\u3002<\/p>\n<p>\u90e8\u5206\u90e8\u5206\u3092\u5207\u308a\u53d6\u3063\u305f\u30bd\u30fc\u30b9\u3067\u898b\u3065\u3089\u304b\u3063\u305f\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u5168\u30bd\u30fc\u30b9\u3092\u4ee5\u4e0b\u306b\u8cbc\u308a\u4ed8\u3051\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>[bash]<\/p>\n<div id=\"root\"><\/div>\n<p><script type=\"text\/babel\">\n  class ToDoList extends React.Component{\n    constructor(props){\n      super(props);\n      var maxId = 0;\n      props.datas.forEach(function(data){\n          if (data.id > maxId){\n            maxId = data.id;\n          }\n      });<\/p>\n<p>      this.state = {\n        datas: props.datas,\n        maxId: maxId,\n        content: ''\n      }\n    }<\/p>\n<p>    handleContentChange(ct){\n      this.setState({content: ct});\n    }<\/p>\n<p>    handleOnAdd(){\n      var maxId = this.state.maxId + 1;\n      var datas = this.state.datas.slice();\n      datas.push({id: maxId, content: this.state.content});<\/p>\n<p>      this.setState({maxId: maxId, content: '', datas: datas});\n    }<\/p>\n<p>    handleOnDelete(delid){\n      var datas = this.state.datas.slice();\n      var newDatas = [];\n      datas.forEach(function(data){\n        if (data.id != delid){\n          newDatas.push(data);\n        }\n      });<\/p>\n<p>      this.setState({datas: newDatas});<\/p>\n<p>    }<\/p>\n<p>    render(){\n      return (<\/p>\n<div id=\"toDoList\">\n          <NewToDo\n            content={this.state.content}\n            onAdd={() => this.handleOnAdd()}\n            onContentChange={(ct) => this.handleContentChange(ct)}\n            \/>\n          <DataList datas={this.state.datas} onDelete={(id) => this.handleOnDelete(id)}\/>\n        <\/div>\n<p>      );\n    }\n  }<\/p>\n<p>  class NewToDo extends React.Component{\n    constructor(props){\n      super(props);\n    }<\/p>\n<p>    handleClick(){\n      this.props.onAdd();\n    }<\/p>\n<p>    handleChange(event){\n      var val = event.target.value;\n      this.props.onContentChange(val);\n    }<\/p>\n<p>    render(){\n      return (<\/p>\n<div id=\"newToDo\">\n          <label>\u30b3\u30f3\u30c6\u30f3\u30c4<\/label>\n          <input type=\"text\" name=\"content\"\n           value={this.props.content}\n           onChange={(e) => this.handleChange(e)}\/>\n          <button onClick={()=> this.handleClick()}>\n            \u8ffd\u52a0\n          <\/button>\n        <\/div>\n<p>      );\n    }\n  }<\/p>\n<p>  class DataList extends React.Component{\n    constructor(props){\n      super(props);\n    }<\/p>\n<p>    handleOnDelete(id){\n      this.props.onDelete(id);\n    }<\/p>\n<p>    render() {\n      var dlist = [];\n      var i;<\/p>\n<p>      \/*\n      this.props.datas.forEach(function(data){\n        dlist.push(<DataLine data={data} key={data.id} onDelete={() => evH(data.id)}\/>);\n      });\n      *\/\n      for (i=0; i < this.props.datas.length; i++){\n        var data = this.props.datas[i];\n        dlist.push(<DataLine data={data} key={data.id} onDelete={(id) => this.handleOnDelete(id)}\/>);\n      }<\/p>\n<p>      return (<\/p>\n<div id=\"dataList\">\n          {dlist}\n        <\/div>\n<p>      );\n    }\n  }<\/p>\n<p>  class DataLine extends React.Component{\n    constructor(props){\n      super(props);\n    }<\/p>\n<p>    handleClick(event){\n      this.props.onDelete(this.props.data.id);\n    }<\/p>\n<p>    render(){\n      return (<\/p>\n<div>\n          <button onClick={() => this.handleClick()}>\u524a\u9664<\/button>\n          {this.props.data.id} --- {this.props.data.content}\n        <\/div>\n<p>      );\n    }\n  }<\/p>\n<p>  var DATAS = [\n    {id:1, content:\"Softbank\u89e3\u7d04\"},\n    {id:2, content:\"R-SIM10\u8cfc\u5165\"},\n    {id:3, content:\"\u570f\u5916\u75c5\u3092\u514b\u670d\u3059\u308bSIM\u30d5\u30ea\u30fc\u30eb\u30fc\u30bf\u30fc\u30b2\u30c3\u30c8\"},\n    {id:4, content:\"\u697d\u5929\u30e2\u30d0\u30a4\u30eb\u7533\u3057\u8fbc\u307f\"}\n  ]<\/p>\n<p>  ReactDOM.render(\n    <ToDoList datas={DATAS} \/>,\n    document.getElementById(\"root\")\n  );<\/p>\n<p><\/script><br \/>\n[\/bash]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3067\u306f ReactJS \u7b2c\uff12\u56de\u76ee\u3044\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002 \u4eca\u56de\u306f\u4e0b\u56f3\u306e\u3088\u3046\u306a\u611f\u3058\u304c\u5b8c\u6210\u56f3\u3067\u3059\u3002 \u5358\u7d14\u306bToDo\u304c\u4e00\u89a7\u3055\u308c\u3066\u304a\u308a\u3001ToDo\u306e\u6a2a\u306b\u306f\u524a\u9664\u30dc\u30bf\u30f3\u304c\u3042\u308a\u3002 ToDo\u3092\u8ffd\u52a0\u3057\u305f\u3044\u5834\u5408\u306f\u4e0a\u90e8\u306e\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306b\u6587\u5b57\u3092\u5165\u529b\u3057 \u8ffd\u52a0\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3002 \u305f\u3063\u305f\u3053\u308c\u3060\u3051\u3067\u3059\u3002 \u307e\u3041\u3053\u306e\u305f\u3063\u305f\u3053\u308c\u3060\u3051\u304c\u7d50\u69cb\u96e3\u3057\u3044\u3093\u3067\u3059\u3051\u3069\u306d\u3002 \u3067\u306f\u3044\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002 \u307e\u305a\u306f\u521d\u671f\u5024\u3068\u306a\u308b\u5909\u6570\u3092\u3053\u3093\u306a\u611f\u3058\u3067\u7528\u610f\u3057\u307e\u3059\u3002 [bash] var DATAS = [ {id:1, content:&#8221;Softbank\u89e3\u7d04&#8221;}, {id:2, content:&#8221;R-SIM10\u8cfc\u5165&#8221;}, {id:3, content:&#8221;\u570f\u5916\u75c5\u3092\u514b\u670d\u3059\u308bSIM\u30d5\u30ea\u30fc\u30eb\u30fc\u30bf\u30fc\u30b2\u30c3\u30c8&#8221;}, {id:4, content:&#8221;\u697d\u5929\u30e2\u30d0\u30a4\u30eb\u7533\u3057\u8fbc\u307f&#8221;} ] [\/bash] \u3053\u306e\u5909\u6570\u304cToDo\u30ea\u30b9\u30c8\u306e\u521d\u671f\u5024\u3067\u3059\u3002 \u3067\u306f\u6b21\u3001\u753b\u9762\u30a4\u30e1\u30fc\u30b8\u304b\u3089\u3001\u4f55\u500b\u306e\u72ec\u81ea\u30af\u30e9\u30b9\u3092\u5b9a\u7fa9\u3057\u306a\u304d\u3083\u3044\u3051\u306a\u3044\u304b\u8003\u3048\u307e\u3057\u3087\u3046\u3002 \u7c21\u5358\u306b\u8a00\u3063\u3066\u307e\u3059\u304c\u3001\u3053\u308c\u304b\u306a\u308a\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\u3067\u3059\u3002 \u8981\u306f\u3069\u3093\u306a\u304c\u5b8c\u6210\u56f3\u304c\u3042\u308b\u304b\u3089\u3001\u3069\u3046\u3044\u3046\u30d1\u30fc\u30c4\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u753b\u9762\u3092\u4f5c\u308d\u3046\u304b\uff1f\uff1f \u3068\u8003\u3048\u308b\u306e\u3067\u3059\u3002\u305d\u306e\u30d1\u30fc\u30c4\u304c class\u3067\u3042\u308a\u3001\u305d\u306e class\u304c\u72ec\u81ea\u30bf\u30b0\u306a\u3093\u3067\u3059\u306d\u3002 ToDo\u30ea\u30b9\u30c8\u306f\u81f3\u3063\u3066\u30b7\u30f3\u30d7\u30eb\u3002 ToDo\u306e\u4e00\u89a7\u3068\u306a\u308b\u30d1\u30fc\u30c4\u3002\u3053\u308c\u21d3\u21d3\u21d3\u3002 \u3068ToDo\u3092\u8ffd\u52a0\u3059\u308b\u305f\u3081\u306e\u30d1\u30fc\u30c4\u3002\u3053\u308c\u21d3\u21d3\u21d3\u3002 \u305d\u3057\u3066ToDo\u306e\u4e00\u89a7\u306e\u4e00\u884c\u3092\u69cb\u6210\u3059\u308b\u30d1\u30fc\u30c4\u3002\u3053\u308c\u21d3\u21d3\u21d3\u3002 \u30d1\u30fc\u30c4\u306f\u6c7a\u307e\u308a\u307e\u3057\u305f\u306e\u3067\u3001\u3053\u306e\u30d1\u30fc\u30c4\u3092\u30af\u30e9\u30b9\u3068\u3057\u3066\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3059\u3002 \u307e\u305a\u6700\u521d\u306e\u30d1\u30fc\u30c4 ToDo\u4e00\u89a7\u3092\u3000DataList\u3002 \u6b21\u306bToDo\u3092\u8ffd\u52a0\u3059\u308b\u30d1\u30fc\u30c4\u3092 NewToDo\u3002 ToDo\u306e\u4e00\u884c\u3092\u69cb\u6210\u3059\u308b\u30d1\u30fc\u30c4\u3092\u3000DataLine \u6700\u5f8c\u306b\u3053\u308c\u3089\u5168\u90e8\u3092\u5305\u542b\u3059\u308b ToDoList\u3000\u3068\u3057\u307e\u3059\u3002 \u56f3\u3067\u66f8\u304f\u3068\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\u3002 \u3067\u306f\u307e\u305aToDo\u4e00\u89a7\u3067\u3042\u308b\u3000DataList\u3092\u30af\u30e9\u30b9\u3068\u3057\u3066\u5b9a\u7fa9\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002 [bash] class DataList extends React.Component{ constructor(props){ super(props); } handleOnDelete(id){ this.props.onDelete(id); } render() { var dlist = []; var i; for (i=0; i < this.props.datas.length; i++){ var data = this.props.datas[i]; dlist.push( this.handleOnDelete(id)}\/>); } return ( {dlist} ); } } [\/bash] \u306a\u3093\u306e\u3053\u3068\u304b\u7406\u89e3\u3067\u304d\u307e\u3059\u304b\uff1f \u666e\u901a\u96e3\u3057\u3044\u306a\u3041\u3068\u601d\u3044\u307e\u3059\u3088\u306d\u3002 \u30af\u30e9\u30b9\u5b9a\u7fa9\u306e\u8aac\u660e\u306f HelloWorld\u3092\u51fa\u529b\u3059\u308b\u90e8\u5206\u3067\u3084\u3063\u305f\u306e\u3067\u5272\u611b\u3057\u307e\u3059\u3002 \u3067\u306f \u6b21\u306econstructor\u3000\u3068\u306f\u4f55\u3067\u3057\u3087\u3046\u304b\u30fb\u30fb\u30fb \u8981\u306f\u30af\u30e9\u30b9\u306e\u521d\u671f\u5316\u51e6\u7406\u3092\u3053\u3053\u3067\u884c\u3044\u307e\u3059\u3088\u3000\u3068\u3044\u3046\u3053\u3068\u306a\u306e\u3067\u3059\u304c\u30fb\u30fb \u521d\u671f\u5316\u3067\u3059\u308b\u3053\u3068\u306f\u7279\u306b\u306a\u3044\u306e\u3067\u3001\u304a\u6c7a\u307e\u308a\u306e\u304a\u307e\u3058\u306a\u3044 super(props)\u3060\u3051\u3092\u8a18\u8ff0\u3057\u3066\u304a\u304d\u307e\u3059\u3002 [bash] constructor(props){ super(props); } [\/bash] \u6b21\u306e handleOnDelete \u3053\u308c\u306a\u3093\u3067\u3059\u304c\u30fb\u30fb \u5fc5\u8981\u3067\u3059\u304c\u3001\u3053\u306e\u8aac\u660e\u306f\u5f8c\u56de\u3057\u306b\u3057\u307e\u3059\u3002 [bash] handleOnDelete(id){ this.props.onDelete(id); } [\/bash] \u6700\u5f8c\u306b render\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002 HelloWorld\u3067\u3082\u3084\u3063\u305f\u3088\u3046\u306b\u3001render\u30e1\u30bd\u30c3\u30c9\u3067\u3001\u3053\u306e\u30af\u30e9\u30b9\u304c\u51fa\u529b\u3059\u308b HTML\u30bf\u30b0\u3092\u69cb\u7bc9\u3059\u308b\u3093\u3067\u3059\u3002 ToDo\u306e\u4e00\u89a7\u306a\u3093\u3067\u3001\u3053\u306e\u30af\u30e9\u30b9\u3092\u4f5c\u308b\u3068\u304d\u306bToDo\u306e\u4e00\u89a7\u3068\u306a\u308b\u30c7\u30fc\u30bf\u3092\u5f15\u304d\u6e21\u3057\u3066\u3082\u3089\u3046\u3053\u3068\u3092\u60f3\u5b9a\u3057\u307e\u3059\u3002 \u305d\u308c\u304c\u3000this.props.datas\u3000\u3068\u3044\u3046\u5909\u6570\u3067\u53c2\u7167\u3067\u304d\u307e\u3059\u3002 render\u30e1\u30bd\u30c3\u30c9\u306e\u4e2d\u3067\u306f\u3001\u3053\u306e\u5909\u6570\u3092\u30eb\u30fc\u30d7\u3067\u56de\u3057\u3066\u3001 dlist\u3068\u3044\u3046\u5909\u6570\u306b push\u3057\u3066\u3044\u3063\u3066\u307e\u3059\u3002 push\u3059\u308b\u5185\u5bb9\u306f\u3001ToDo\u306e\uff11\u884c\u3092\u69cb\u6210\u3059\u308b DataLine\u30bf\u30b0\uff08\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\uff09\u3067\u3059\u3002 \u305d\u3057\u3066 render\u30e1\u30bd\u30c3\u30c9\u304c\u30ea\u30bf\u30fc\u30f3\u3059\u308b\u5185\u5bb9\u306f &lt;div&gt;\u30bf\u30b0\u306e\u4e2d\u306b\u4e0a\u8a18\u306e\u914d\u5217\u5909\u6570\u3092\u7d44\u307f\u8fbc\u3093\u3060\u3082\u306e\u306b\u306a\u308a\u307e\u3059\u3002 [bash] render() { var dlist = []; var i; for (i=0; i < this.props.datas.length; i++){ var data = this.props.datas[i]; dlist.push( this.handleOnDelete(id)}\/>); } return ( {dlist} ); } [\/bash] \u809d\u5fc3\u306a\u3053\u3068\u3092\u5fd8\u308c\u3066\u3044\u307e\u3057\u305f\u3002 \uff13\u3064\u306e\u30d1\u30fc\u30c4\u3092\u5305\u542b\u3059\u308b\u4e00\u756a\u5927\u304d\u306a\u30d1\u30fc\u30c4\u304c\u5fc5\u8981\u3067\u3059\u3002\u3053\u308c\u3092ToDoList\u30af\u30e9\u30b9\u3068\u3057\u307e\u3059\u3002 ToDoList\u30af\u30e9\u30b9\u306e\u30bd\u30fc\u30b9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\u3002 [bash] class ToDoList extends React.Component{ constructor(props){ super(props); this.state = { datas: props.datas } } render(){ return ( ); } } [\/bash] ToDoList\u30af\u30e9\u30b9\u306e render\u30e1\u30bd\u30c3\u30c9\u3067\u306f\u3001NewToDo\u30bf\u30b0\u3068DataList\u30bf\u30b0\u3092\u69cb\u7bc9\u3057\u3066\u3044\u308b\u306e\u304c\u89e3\u308b\u3068\u601d\u3044\u307e\u3059\u3002 \u305d\u3057\u3066 DataList\u30bf\u30b0\u306e datas\u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u306b this.state.datas\u3000\u3092\u6e21\u3057\u3066\u3044\u307e\u3059\u3002 this.state.datas\u3000\u3068\u306f\u4f55\u3067\u3057\u3087\u3046\u304b\uff1f state\u3068\u306f\u30af\u30e9\u30b9\u304c\u7ba1\u7406\u3059\u308b\u52d5\u7684\u306a\u5909\u6570\u306e\u3088\u3046\u306a\u3082\u306e\u3067\u3059\u3002 ReactJS\u3067\u306f state\u306e\u5024\u304c\u5909\u66f4\u3055\u308c\u308b\u3068\u3001\u81ea\u52d5\u7684\u306b\u305d\u306estate\u306e\u5024\u304c\u6307\u3057\u793a\u3059 HTML\u3092\u66f8\u304d\u63db\u3048\u308b\u4ed5\u7d44\u307f \u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3059\u3002 \u3067\u3001\u5b9f\u969b\u306b\u3053\u3053\u3067\u306f\u3000this.state.datas\u3000\u306b\u4f55\u304c\u5165\u3063\u3066\u3044\u308b\u304b\u3068\u3044\u3046\u3068\u3001\u6700\u521d\u306e\u65b9\u3067\u8aac\u660e\u3057\u305f ToDo\u30ea\u30b9\u30c8\u306e\u4e2d\u8eab\u3067\u3042\u308b DATAS\u5909\u6570\u304c\u5165\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002 \u3053\u308c\u3067\u306f\u8a00\u8449\u8db3\u3089\u305a\u3067\u3059\u306d\u3002 ToDoList\u30af\u30e9\u30b9\u304c\u5168\u30af\u30e9\u30b9\u306e\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u306e\u30af\u30e9\u30b9\u3067\u3042\u308b\u306e\u3067\u3001 ReactDOM.render \u3067\u306f\u3000ToDoList\u30af\u30e9\u30b9\u3092\u3000render\u3057\u3066\u3082\u3089\u3044\u307e\u3059\u3002 \u30bd\u30fc\u30b9\u3067\u66f8\u304f\u3068\u3053\u3093\u306a\u611f\u3058\u3002 [bash] ReactDOM.render( , document.getElementById(&#8220;root&#8221;) ); [\/bash] \u3067\u3001\u3053\u308c\u3060\u3051\u3060\u3068\u3001ToDoList\u306e\u521d\u671f\u5024\u3092\u6e21\u305b\u3066\u3044\u306a\u3044\u3053\u3068\u306b\u306a\u308b\u306e\u3067\u3001 \u6b63\u3057\u304f\u306f\u3000\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002 \u8981\u306f\u30af\u30e9\u30b9\u5185\u3067\u4f7f\u3044\u305f\u3044\u30c7\u30fc\u30bf\u306f \u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u3067\u6e21\u305d\u3046\u306d\u3002\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002 \u3067\u3001\u30c7\u30fc\u30bf\u3068\u306f\u52d5\u7684\u306b\u5909\u5316\u3059\u308b\u3082\u306e\u306a\u306e\u3067\u3000\uff5b\uff5d\u3000\u3067\u62ec\u3063\u3066\u6e21\u305d\u3046\u306d\u3068\u3044\u3046\u30eb\u30fc\u30eb\u306b\u306a\u308a\u307e\u3059\u3002 [bash] var DATAS = [ {id:1, content:&#8221;Softbank\u89e3\u7d04&#8221;}, {id:2, content:&#8221;R-SIM10\u8cfc\u5165&#8221;}, {id:3, content:&#8221;\u570f\u5916\u75c5\u3092\u514b\u670d\u3059\u308bSIM\u30d5\u30ea\u30fc\u30eb\u30fc\u30bf\u30fc\u30b2\u30c3\u30c8&#8221;}, {id:4, content:&#8221;\u697d\u5929\u30e2\u30d0\u30a4\u30eb\u7533\u3057\u8fbc\u307f&#8221;} ] ReactDOM.render( , document.getElementById(&#8220;root&#8221;) ); [\/bash] \u3067\u3001\u307e\u3060\u3053\u308c\u3067\u3082 DataList\u30af\u30e9\u30b9\u306e\u3000this.props.datas\u3000\u306b DATAS\u306e\u5024\u304c\u6e21\u3063\u3066\u3044\u304f\u4ed5\u7d44\u307f\u304c\u8aac\u660e\u3067\u304d\u3066\u3044\u307e\u305b\u3093\u306d\u3002 DataList\u30af\u30e9\u30b9\u306f\u3000ToDoList\u30af\u30e9\u30b9\u306e\u5b50\u4f9b\u3067\u3059\u3002\u3064\u307e\u308a DataList\u30af\u30e9\u30b9\u306f ToDoList\u30af\u30e9\u30b9\u306erender\u30e1\u30bd\u30c3\u30c9\u3067 \u4f5c\u6210\u3055\u308c\u3001\u305d\u306e\u6642\u306bDataList\u30af\u30e9\u30b9\u304c\u6271\u3046\u5909\u6570\u3068\u3057\u3066 datas\u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u306b DATAS\u3092\u6e21\u3059\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002 \u65e5\u672c\u8a9e\u3067\u66f8\u304f\u3068\u3084\u3084\u3053\u3057\u3044\u3067\u3059\u306d\u3002 \u3064\u307e\u308a\u306f\u3001ToDoList\u30af\u30e9\u30b9\u306erender\u30e1\u30bd\u30c3\u30c9\u3067\u306f\u3000\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u3053\u3068\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002 [bash] class ToDoList extends React.Component{ constructor(props){ super(props); this.state = { datas: props.datas } } render(){ return ( ); } } [\/bash] render\u30e1\u30bd\u30c3\u30c9\u306e\u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u3067\u6e21\u3055\u308c\u305f\u5909\u6570\u306f\u3001 \u30af\u30e9\u30b9\u5185\u3067 props\uff08\u30d7\u30ed\u30d1\u30c6\u30a3\uff09\u3068\u3057\u3066\u53c2\u7167\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002 ToDoList\u30af\u30e9\u30b9\u306f datas\u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u3067\u6e21\u3055\u308c\u305f DATAS\u5909\u6570\u306e\u4e2d\u8eab\u3092\u81ea\u8eab\u306e\u30af\u30e9\u30b9\u306e state\u3068\u3057\u3066\u7ba1\u7406\u3057\u3088\u3046\u3068\u3057\u307e\u3059\u3002 \u3053\u308c\u304c constructor\u306e\u4e2d\u306b\u3042\u308b\u3002 this.state = {datas: this.props.datas}; \u3053\u308c\u3067 ToDoList\u30af\u30e9\u30b9 \u5185\u3067\u306f this.state.datas \u3067 DATAS\u306e\u5185\u5bb9\u3092\u53c2\u7167\u3067\u304d\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002 \u3084\u3063\u3068\u3053\u308c\u3067 DataList\u306b DATAS\u306e\u5024\u304c\u6e21\u308b\u3053\u3068\u304c\u8aac\u660e\u3067\u304d\u307e\u3057\u305f\u304b\u306d\u30fb\u30fb\u30fb \u3067\u306f\u3001\u6b21\u306fDataList\u306e render\u30e1\u30bd\u30c3\u30c9\u3067ToDo\u306e\u4e00\u884c\u4e00\u884c\u3092\u69cb\u6210\u3059\u308bDataLine\u30af\u30e9\u30b9\u3092\u4f5c\u3063\u3066\u3044\u308b\u3068\u3053\u308d\u3092 \u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002 [bash] render() { var dlist = []; var i; for (i=0; i < this.props.datas.length; i++){ var data =...\n<\/p>\n","protected":false},"author":1,"featured_media":1301,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[77],"tags":[72],"class_list":{"0":"post-1541","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-react","8":"tag-reactjs"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/1541","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1541"}],"version-history":[{"count":1,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/1541\/revisions"}],"predecessor-version":[{"id":1542,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/1541\/revisions\/1542"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/media\/1301"}],"wp:attachment":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}