{"id":18974,"date":"2018-12-02T09:00:08","date_gmt":"2018-12-02T00:00:08","guid":{"rendered":"http:\/\/www.techscore.com\/blog\/?p=18974"},"modified":"2018-11-28T14:07:56","modified_gmt":"2018-11-28T05:07:56","slug":"react-when-the-render-will-be-called","status":"publish","type":"post","link":"https:\/\/www.techscore.com\/blog\/2018\/12\/02\/react-when-the-render-will-be-called\/","title":{"rendered":"React: \u305d\u306erender()\u306f\u3044\u3064\u547c\u3070\u308c\u308b\u306e\u304b"},"content":{"rendered":"<p>\u3053\u308c\u306f <a href=\"\/blog\/2018\/11\/22\/techscore-advent-calendar-2018\/\">TECHSCORE Advent Calendar 2018<\/a> \u306e\uff12\u65e5\u76ee\u306e\u8a18\u4e8b\u3067\u3059\u3002<br \/>\nReact \u3067\u7121\u90aa\u6c17\u306b\u958b\u767a\u3092\u3057\u3066\u3044\u308b\u3068\u3001\u3084\u305f\u3089\u3068 <code>render()<\/code> \u304c\u547c\u3070\u308c\u308b\u306e\u304c\u6c17\u306b\u306a\u308a\u307e\u3059\u3002 PureComponent \u3092\u4f7f\u3046\u3068 <code>render()<\/code> \u306e\u547c\u3073\u51fa\u3057\u3092\u5c11\u306a\u304f\u3067\u304d\u308b\u3053\u3068\u306f\u3001\u306a\u3093\u3068\u306a\u304f\u77e5\u3063\u3066\u306f\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u3082\u305d\u3082\u3069\u3046\u3044\u3046\u5834\u5408\u306b <code>render()<\/code> \u304c\u547c\u3070\u308c\u308b\u306e\u304b\u3001 State \u3084 Context\u3001 \u306f\u305f\u307e\u305f Redux \u3092\u4f7f\u3063\u305f\u3068\u304d\u306b <code>render()<\/code> \u306e\u547c\u3070\u308c\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u304c\u305d\u308c\u305e\u308c\u3069\u3046\u9055\u3046\u306e\u304b\u3001\u3044\u307e\u3044\u3061\u3088\u304f\u308f\u304b\u3063\u3066\u3044\u307e\u305b\u3093\u3002\u3044\u308d\u3044\u308d\u305f\u3063\u3077\u308a\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<h3>\u76ee\u6b21<\/h3>\n<ul>\n<li><a href=\"#introduction\">\u6e96\u5099<\/a><\/li>\n<li><a href=\"#state\">State<\/a><\/li>\n<ul>\n<li><a href=\"#state_vanilla\">Vanilla State<\/a><\/li>\n<li><a href=\"#state_purecomponent\">PureComponent<\/a><\/li>\n<li><a href=\"#state_allowfunction\">Props \u306b Allow Function \u3092\u76f4\u63a5\u6e21\u3059<\/a><\/li>\n<\/ul>\n<li><a href=\"#context\">Context<\/a><\/li>\n<ul>\n<li><a href=\"#context_vanilla\">Vanilla Context<\/a><\/li>\n<li><a href=\"#context_purecomponent\">PureComponent<\/a><\/li>\n<li><a href=\"#context_own_provider\">\u72ec\u81ea\u306e Provider \u3092\u4f7f\u3046<\/a><\/li>\n<li><a href=\"#context_own_provider_consumer\">\u72ec\u81ea\u306e Provider\u3001 Consumer \u3092\u4f7f\u3046<\/a><\/li>\n<\/ul>\n<li><a href=\"#redux\">Redux<\/a><\/li>\n<ul>\n<li><a href=\"#redux_v5\">react-redux v5.1.1<\/a><\/li>\n<li><a href=\"#redux_setstate\">\u5bc4\u308a\u9053: Redux \u306f\u3069\u3046\u3084\u3063\u3066 `render()` \u3092\u547c\u3093\u3067\u3044\u308b\u306e\u304b<\/a><\/li>\n<li><a href=\"#redux_v6\">react-redux v6.0.0-beta.1<\/a><\/li>\n<\/ul>\n<li><a href=\"#conclusions\">\u307e\u3068\u3081<\/a><\/li>\n<\/ul>\n<h2 id=\"introduction\">\u6e96\u5099<\/h2>\n<p>\u56f3\uff11\u306e\u3088\u3046\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u8003\u3048\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/baseapp.png\" rel=\"facebox\" rel=\"attachment wp-att-19112\"><img loading=\"lazy\" src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/baseapp.png\" alt=\"\" width=\"622\" height=\"462\" class=\"aligncenter size-full wp-image-19112\" srcset=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/baseapp.png 622w, https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/baseapp-300x223.png 300w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><\/a><\/p>\n<div align=\"center\">\u56f3\uff11 \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u6982\u8981<\/div>\n<p>\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8 App \u306f\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8 A\u3001X \u3092\u542b\u307f\u3001 A\u3001X \u306f\u305d\u308c\u305e\u308c B\u3001Y \u3092\u3001 B\u3001Y \u306f\u305d\u308c\u305e\u308c C\u3001Z \u3092\u542b\u307f\u307e\u3059\u3002 B \u306b\u306f\u30dc\u30bf\u30f3\u304c\u914d\u7f6e\u3055\u308c\u3066\u304a\u308a\u3001\u3053\u306e\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u3001 Y \u306b\u8868\u793a\u3055\u308c\u305f\u6570\u5b57\u304c\u30ab\u30a6\u30f3\u30c8\u30a2\u30c3\u30d7\u3055\u308c\u307e\u3059\u3002<br \/>\n\u64ec\u4f3c\u30b3\u30fc\u30c9\u306b\u3059\u308c\u3070\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" title=\"\u64ec\u4f3c\u30b3\u30fc\u30c9\" >const App = () =&gt; &lt;&gt;\n  &lt;A \/&gt;\n  &lt;X \/&gt;\n&lt;\/&gt;;\n\nconst A = () =&gt; &lt;B \/&gt;\nconst B = () =&gt; &lt;&gt;\n  &lt;button onClick={countUp}&gt;countUp&lt;\/button&gt;\n  &lt;C \/&gt;\n&lt;\/&gt;\nconst C = () =&gt; &lt;\/&gt;\n\nconst X = () =&gt; &lt;Y \/&gt;\nconst Y = () =&gt; &lt;&gt;\n  &lt;div&gt;{count}&lt;\/div&gt;\n  &lt;Z \/&gt;\n&lt;\/&gt;\nconst Z = () =&gt; &lt;\/&gt;<\/pre>\n<p>Y \u306b\u8868\u793a\u3059\u308b\u6570\u5b57\u306f\u3069\u3053\u304b\u306b\u5024\u3092\u4fdd\u6301\u3057\u3066\u72b6\u614b\u3068\u3057\u3066\u7ba1\u7406\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u304c\u3001 React \u306e\u5834\u5408\u3001\u72b6\u614b\u7ba1\u7406\u306e\u65b9\u6cd5\u306f\u3044\u304f\u3064\u304b\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>State<\/li>\n<li>Context<\/li>\n<li>Redux<\/li>\n<\/ul>\n<p>\u4ee5\u4e0b\u3001\u305d\u308c\u305e\u308c\u306e\u65b9\u6cd5\u3067\u72b6\u614b\u7ba1\u7406\u3092\u884c\u306a\u3063\u305f\u5834\u5408\u306b\u3001\u3069\u306e\u3088\u3046\u306b <code>render()<\/code> \u304c\u547c\u3070\u308c\u308b\u306e\u304b\u898b\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h2 id=\"state\">State<\/h2>\n<h3 id=\"state_vanilla\">State: Vanilla State<\/h3>\n<p>\u300c\u5024\u306e\u64cd\u4f5c\u306b\u95a2\u3059\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8 B\u300d\u3068\u300c\u5024\u306e\u8868\u793a\u306b\u95a2\u3059\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8 Y\u300d\u3001\u4e21\u8005\u306e\u5171\u901a\u306e\u7956\u5148\u3067\u3042\u308b App \u306b State \u3092\u4fdd\u6301\u3057\u307e\u3059\u3002 State \u3092\u64cd\u4f5c\u3059\u308b <code>countUp()<\/code> \u3068 State \u306e\u5024\u3092\u8868\u3059 <code>count<\/code> \u3092 Props \u3067\u4e0b\u4f4d\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3078\u3068\u6e21\u3057\u307e\u3059\u3002<br \/>\n\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u3001 App \u306e <code>setState()<\/code> \u304c\u547c\u3070\u308c\u3001\u3055\u3089\u306b <code>render()<\/code> \u304c\u547c\u3070\u308c\u307e\u3059\u3002 A \u306e <code>render()<\/code> \u304c\u547c\u3070\u308c\u308b\u3068\u3001 A \u304a\u3088\u3073 X \u306e <code>render()<\/code>\u3001 B \u304a\u3088\u3073 Y \u306e <code>render()<\/code>\u3001 C \u304a\u3088\u3073 Z \u306e <code>render()<\/code> \u304c\u6570\u73e0\u7e4b\u304e\u306b\u547c\u3070\u308c\u307e\u3059\u3002<\/p>\n<p>\u56f3\u3067\u306f\u3001\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u305f\u969b\u306b <code>render()<\/code> \u304c\u547c\u3070\u308c\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u8d64\u4e38\u3092\u4ed8\u3051\u3066\u3044\u307e\u3059\u3002<br \/>\n\u307e\u305f\u3001\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u305f\u5f8c\u306e\u5236\u5fa1(\u306e\u30a4\u30e1\u30fc\u30b8)\u3092\u30aa\u30ec\u30f3\u30b8\u8272\u306e\u77e2\u5370\u3067\u8868\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/state.png\" rel=\"facebox\" rel=\"attachment wp-att-19085\"><img loading=\"lazy\" src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/state.png\" alt=\"\" width=\"622\" height=\"462\" class=\"aligncenter size-full wp-image-19085\" srcset=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/state.png 622w, https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/state-300x223.png 300w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><\/a><\/p>\n<div align=\"center\">\u56f32 State \u3092\u4f7f\u3046<\/div>\n<div align=\"right\"><a href=\"https:\/\/codepen.io\/higashi-masaru\/pen\/Oaxgor\">Try it on CodePen<\/a><\/div>\n<h3 id=\"state_purecomponent\">State: PureComponent<\/h3>\n<p>PureComponent \u3067\u306f Props \u306b\u5909\u5316\u306e\u306a\u3044\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e <code>render()<\/code> \u306f\u547c\u3070\u308c\u306a\u3044\u305f\u3081\u3001\u7c21\u5358\u306b <code>render()<\/code> \u306e\u547c\u3073\u51fa\u3057\u3092\u6291\u5236\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068 App \u306e <code>state.count<\/code> \u304c\u5909\u5316\u3057\u307e\u3059\u306e\u3067\u3001 App \u304a\u3088\u3073 <code>state.count<\/code> \u3092 Props \u3068\u3057\u3066\u6e21\u3057\u3066\u3044\u308b X\u3001Y \u306e <code>render()<\/code> \u304c\u547c\u3070\u308c\u307e\u3059\u3002\u3057\u304b\u3057 Z \u306b\u306f Props \u3092\u6e21\u3057\u3066\u3044\u307e\u305b\u3093\u306e\u3067 Z \u306e <code>render()<\/code> \u306f\u547c\u3070\u308c\u307e\u305b\u3093\u3002<br \/>\n\u307e\u305f A\u3001B \u306b\u6e21\u3057\u3066\u3044\u308b <code>countUp()<\/code> \u306f\u5909\u5316\u3057\u307e\u305b\u3093\u306e\u3067\u3001 A\u3001B \u306e <code>render()<\/code> \u306f\u547c\u3070\u308c\u307e\u305b\u3093\u3002\u3055\u3089\u306b C \u306b\u306f Props \u3092\u6e21\u3057\u3066\u3044\u307e\u305b\u3093\u306e\u3067\u3001 C \u306e <code>render()<\/code> \u3082\u547c\u3070\u308c\u307e\u305b\u3093\u3002<\/p>\n<p><a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/state_pure.png\" rel=\"facebox\" rel=\"attachment wp-att-19084\"><img loading=\"lazy\" src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/state_pure.png\" alt=\"\" width=\"622\" height=\"462\" class=\"aligncenter size-full wp-image-19084\" srcset=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/state_pure.png 622w, https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/state_pure-300x223.png 300w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><\/a><\/p>\n<div align=\"center\">\u56f33 State \u3092\u4f7f\u3046\u3002 PureComponent \u306e\u5834\u5408<\/div>\n<div align=\"right\"><a href=\"https:\/\/codepen.io\/higashi-masaru\/pen\/VVxYOz\">Try it on CodePen<\/a><\/div>\n<h3 id=\"state_allowfunction\">State: Props \u306b Allow Function \u3092\u76f4\u63a5\u6e21\u3059<\/h3>\n<p>PureComponent \u3092\u4f7f\u3063\u305f\u5834\u5408\u3067\u3082\u3001 <code>countUp()<\/code> \u3092 Props \u306b\u6e21\u3059\u969b\u306b\u305d\u306e\u5834\uff08\u307e\u305f\u306f <code>render()<\/code> \u5185\uff09\u3067\u4f5c\u6210\u3057\u305f\u95a2\u6570\u3092\u6e21\u3059\u3068\u3001 <code>render()<\/code> \u304c\u5b9f\u884c\u3055\u308c\u308b\u6bce\u306b\u7570\u306a\u308b\u5024\u3068\u306a\u308b\u305f\u3081\u3001 A\u3001B \u306e <code>render()<\/code> \u3082\u547c\u3070\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" >  render() {\n    console.log('App: render');\n    return (\n      &lt;React.Fragment&gt;\n        {\/* Props\u306b\u76f4\u63a5\u95a2\u6570\u3092\u6e21\u3059 *\/}\n        &lt;A countUp={() =&gt; this.setState(state =&gt; ({ count: state.count + 1 }))} \/&gt;\n        &lt;X count={this.state.count} \/&gt;\n      &lt;\/React.Fragment&gt;\n    );\n  }<\/pre>\n<p><a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/state_pure_func_in_render.png\" rel=\"facebox\" rel=\"attachment wp-att-19083\"><img loading=\"lazy\" src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/state_pure_func_in_render.png\" alt=\"\" width=\"622\" height=\"462\" class=\"aligncenter size-full wp-image-19083\" srcset=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/state_pure_func_in_render.png 622w, https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/state_pure_func_in_render-300x223.png 300w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><\/a><\/p>\n<div align=\"center\">\u56f34 State \u3092\u4f7f\u3046\u3002 PureComponent \u306e\u5834\u5408\u3002\u305d\u306e\u5834\u3067\u4f5c\u3063\u305f\u95a2\u6570\u3092\u6e21\u3059<\/div>\n<div align=\"right\"><a href=\"https:\/\/codepen.io\/higashi-masaru\/pen\/EOLaBK\">Try it on CodePen<\/a><\/div>\n<h2 id=\"context\">Context<\/h2>\n<h3 id=\"context_vanilla\">Context: Vanilla Context<\/h3>\n<p>Context \u3092\u4f7f\u3046\u3053\u3068\u3067 Props \u306e\u30d0\u30b1\u30c4\u30ea\u30ec\u30fc\u3092\u56de\u907f\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u304c\u3001\u72b6\u614b\u3092 App \u306e State \u306b\u6301\u3063\u3066\u3057\u307e\u3046\u3068\u3001\u6700\u521d\u306e State \u3092\u4f7f\u3063\u305f\u5834\u5408\u3068\u540c\u69d8\u306b\u5168\u3066\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e <code>render()<\/code> \u304c\u547c\u3070\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/context.png\" rel=\"facebox\" rel=\"attachment wp-att-19081\"><img loading=\"lazy\" src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/context.png\" alt=\"\" width=\"622\" height=\"462\" class=\"aligncenter size-full wp-image-19081\" srcset=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/context.png 622w, https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/context-300x223.png 300w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><\/a><\/p>\n<div align=\"center\">\u56f35 Context \u3092\u4f7f\u3046<\/div>\n<div align=\"right\"><a href=\"https:\/\/codepen.io\/higashi-masaru\/pen\/MzEvge\">Try it on CodePen<\/a><\/div>\n<h3 id=\"context_purecomponent\">Context: PureComponent<\/h3>\n<p>Context \u3092\u4f7f\u3044\u72b6\u614b\u3092 App \u306e State \u306b\u6301\u3063\u305f\u5834\u5408\u3067\u3082\u3001 PureComponent \u3092\u4f7f\u3048\u3070 <code>render()<\/code> \u306e\u547c\u3073\u51fa\u3057\u3092\u6291\u5236\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/context_pure.png\" rel=\"facebox\" rel=\"attachment wp-att-19080\"><img loading=\"lazy\" src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/context_pure.png\" alt=\"\" width=\"622\" height=\"462\" class=\"aligncenter size-full wp-image-19080\" srcset=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/context_pure.png 622w, https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/context_pure-300x223.png 300w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><\/a><\/p>\n<div align=\"center\">\u56f36 Context \u3092\u4f7f\u3046\u3002 PureComponent \u306e\u5834\u5408<\/div>\n<div align=\"right\"><a href=\"https:\/\/codepen.io\/higashi-masaru\/pen\/zMjGWw\">Try it on CodePen<\/a><\/div>\n<h3 id=\"context_own_provider\">Context: \u72ec\u81ea\u306e Provider \u3092\u4f7f\u3046<\/h3>\n<p>App \u306b\u76f4\u63a5 State \u3092\u4fdd\u6301\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u72ec\u81ea\u306e Provider \u3092\u4f7f\u3046\u3053\u3068\u3067 <code>render()<\/code> \u306e\u6570\u73e0\u7e4b\u304e\u3092\u5207\u65ad\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/content_own_provider.png\" rel=\"facebox\" rel=\"attachment wp-att-19104\"><img loading=\"lazy\" src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/content_own_provider.png\" alt=\"\" width=\"622\" height=\"462\" class=\"aligncenter size-full wp-image-19104\" srcset=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/content_own_provider.png 622w, https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/content_own_provider-300x223.png 300w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><\/a><\/p>\n<div align=\"center\">\u56f36 Context \u3092\u4f7f\u3046\u3002\u72ec\u81ea\u306e Provider \u3092\u4f7f\u3046\u5834\u5408<\/div>\n<div align=\"right\"><a href=\"https:\/\/codepen.io\/higashi-masaru\/pen\/bQooBR\">Try it on CodePen<\/a><\/div>\n<h3 id=\"context_own_provider_consumer\">Context: \u72ec\u81ea\u306e Provider\u3001Consumer \u3092\u4f7f\u3046<\/h3>\n<p>\u72ec\u81ea\u306e Provider \u306b\u52a0\u3048\u3001\u72ec\u81ea\u306e Consumer \u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u3055\u3089\u306b <code>render()<\/code> \u306e\u4f1d\u642c\u7bc4\u56f2\u3092\u9650\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/content_own_provider_consumer.png\" rel=\"facebox\" rel=\"attachment wp-att-19103\"><img loading=\"lazy\" src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/content_own_provider_consumer.png\" alt=\"\" width=\"622\" height=\"462\" class=\"aligncenter size-full wp-image-19103\" srcset=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/content_own_provider_consumer.png 622w, https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/content_own_provider_consumer-300x223.png 300w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><\/a><\/p>\n<div align=\"center\">\u56f37 Context \u3092\u4f7f\u3046\u3002\u72ec\u81ea\u306e Provider\u3001Consumer \u3092\u4f7f\u3046\u5834\u5408<\/div>\n<div align=\"right\"><a href=\"https:\/\/codepen.io\/higashi-masaru\/pen\/PxeOQP\">Try it on CodePen<\/a><\/div>\n<h2 id=\"redux\">Redux<\/h2>\n<h3 id=\"redux_v5\">Redux: react-redux v5.1.1<\/h3>\n<p>Redux \u3092\u4f7f\u3046\u3068\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u968e\u5c64\u306e\u5916\u306b\u72b6\u614b\u3092\u6301\u3064\u3053\u3068\u304c\u3067\u304d\u308b\u305f\u3081\u3001 <code>connect()<\/code> \u3088\u308a\u4e0b\u4f4d\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u307f <code>render()<\/code> \u304c\u547c\u3070\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/redux.png\" rel=\"facebox\" rel=\"attachment wp-att-19082\"><img loading=\"lazy\" src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/redux.png\" alt=\"\" width=\"622\" height=\"462\" class=\"aligncenter size-full wp-image-19082\" srcset=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/redux.png 622w, https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2018\/11\/redux-300x223.png 300w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><\/a><\/p>\n<div align=\"center\">\u56f38 Redux \u3092\u4f7f\u3046<\/div>\n<div align=\"right\"><a href=\"https:\/\/codepen.io\/higashi-masaru\/pen\/OaxxLX\">Try it on CodePen<\/a><\/div>\n<div style=\"\nmargin-left: 20px;\npadding: 0 8px 0 8px;\nborder-style: solid;\nborder-color: #d0d0d0;\nborder-width: 2px;\nborder-radius: 8px;\n\"><\/p>\n<h3 id=\"redux_setstate\">\u5bc4\u308a\u9053: Redux \u306f\u3069\u3046\u3084\u3063\u3066 `render()` \u3092\u547c\u3093\u3067\u3044\u308b\u306e\u304b<\/h3>\n<p>React \u3067\u306f State \u3092\u5909\u5316\u3055\u305b\u308b\u3053\u3068\u3067 `render()` \u304c\u547c\u3070\u308c\u307e\u3059\u3002 Context \u3092\u4f7f\u3063\u305f\u5834\u5408\u3067\u3082\u3069\u3053\u304b\u306b State \u3092\u4fdd\u6301\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3057\u304b\u3057 Redux \u3067\u306f React \u306e\u7ba1\u7406\u5916\u306b\u72b6\u614b\u3092\u6301\u3063\u3066\u304a\u308a\u3001\u3053\u308c\u306f React \u306e State \u3068\u306f\u7121\u95a2\u4fc2\u3067\u3059\u3002<br \/>\n\u3067\u306f\u3001\u3069\u306e\u3088\u3046\u306b Redux \u306e\u72b6\u614b\u5909\u5316\u3092 React \u306b\u4f1d\u3048\u3066\u3044\u308b\u306e\u304b\u3001 react-redux \u306e\u5b9f\u88c5\u3092\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>react-redux \u3067\u306f `connnect()` \u3067 Redux \u306e\u4e16\u754c\u3068 React \u306e\u4e16\u754c\u3092\u7e4b\u304e\u307e\u3059\u3002<br \/>\n`connect()`\u306e<a href=\"https:\/\/github.com\/reduxjs\/react-redux\/blob\/v5.1.1\/src\/connect\/connect.js#L9\">\u5b9f\u88c5<\/a>\u306b\u306f<q>connect is a facade over connectAdvanced.<\/q>\u3068\u3042\u308a\u307e\u3059\u306e\u3067 `connectAdvanced()` \u3092\u898b\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>`connectAdvanced()` \u3067\u306f\u6e21\u3055\u308c\u305f\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u30e9\u30c3\u30d7\u3057\u3066\u8fd4\u3057\u307e\u3059(\u203b)\u304c\u3001\u3053\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b State \u3092<a href=\"https:\/\/github.com\/reduxjs\/react-redux\/blob\/v5.1.1\/src\/components\/connectAdvanced.js#L124\">\u4fdd\u6301<\/a>\u3057\u3066\u3044\u307e\u3059\u3002 Redux \u5074\u3067\u72b6\u614b\u5909\u5316\u304c\u8d77\u3053\u308b\u3068\u3001\u3053\u306e State \u304c<a href=\"https:\/\/github.com\/reduxjs\/react-redux\/blob\/v5.1.1\/src\/components\/connectAdvanced.js#L222\">\u5909\u66f4<\/a>(`setState()`)\u3055\u308c\u307e\u3059\u3002\u3053\u306e\u3068\u304d\u306b\u8a2d\u5b9a\u3055\u308c\u308b`dummyState`\u306f<a href=\"https:\/\/github.com\/reduxjs\/react-redux\/blob\/v5.1.1\/src\/components\/connectAdvanced.js#L10\">\u5e38\u306b\u7a7a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8(`{}`)<\/a>\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u5b9f\u969b\u306b\u306f\u72b6\u614b\u306f\u5909\u5316\u3057\u307e\u305b\u3093\u304c\u3001 `render()` \u306e\u547c\u3073\u51fa\u3057\u9023\u9396\u3092\u767a\u751f\u3055\u305b\u308b\u305f\u3081\u306b `setState()` \u3092\u5b9f\u884c\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n<span style=\"\ncolor: #222222;\nfont-size: 80%;\n\">\u203b \u6b63\u78ba\u306b\u306f\u300c\u6e21\u3055\u308c\u305f\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u8907\u88fd\u3057\u305f\u3082\u306e\u3092\u8fd4\u3059\u95a2\u6570\u3092\u8fd4\u3059\u300d\u3067\u3059\u304c\u3001\u3053\u3053\u306f\u7c21\u5358\u306b\u3002<\/span><\/p>\n<p>\u3082\u3063\u3068\u4f55\u304b\u5225\u306e\u4f1d\u9054\u624b\u6bb5\u304c\u3042\u308b\u306e\u304b\u3068\u601d\u3063\u3066\u3044\u307e\u3057\u305f\u304c\u3001 `this.setState({})` \u3068\u306f\u610f\u5916\u306a\u5b9f\u88c5\u65b9\u6cd5\u3067\u3057\u305f\u3002\n<\/p><\/div>\n<p><\/p>\n<h3 id=\"redux_v6\">Redux: react-redux v6.0.0-beta.1<\/h3>\n<p>react-redux \u306e\u6b21\u671f\u30d0\u30fc\u30b8\u30e7\u30f3(v6.0.0)\u3067\u306f\u5185\u90e8\u7684\u306b Context \u3092\u4f7f\u3046\u5b9f\u88c5\u306b\u5909\u66f4\u3055\u308c\u308b\u4e88\u5b9a\u3067\u3059\u3002<br \/>\n<a href=\"https:\/\/github.com\/reduxjs\/react-redux\/releases\/tag\/v6.0.0-beta.1\">react-redux v6.0.0-beta.1<\/a><\/p>\n<blockquote><p>\ud83c\udf89 This is our first big release supporting the new React Context API!<\/p><\/blockquote>\n<p>v6.0.0-beta.1\u3067\u306f\u5185\u90e8\u5411\u3051\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304c\u65b0\u305f\u306b\u4f5c\u3089\u308c\u3001\u3053\u306e\u5185\u90e8\u306b<a href=\"https:\/\/github.com\/reduxjs\/react-redux\/blob\/v6.0.0-beta.1\/src\/components\/Provider.js#L11-L14\">State\u3092\u4fdd\u6301\u3057\u307e\u3059<\/a>\u3002<br \/>\nRedux\u306e\u72b6\u614b\u5909\u5316\u3092\u3053\u306eState\u306b<a href=\"https:\/\/github.com\/reduxjs\/react-redux\/blob\/v6.0.0-beta.1\/src\/components\/Provider.js#L46-L53\">\u4f1d\u3048\u308b<\/a>\u3053\u3068\u3067 <code>render()<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u3044\u307e\u3059\u3002 <code>this.setState({})<\/code> \u3068\u3044\u3046\u30c6\u30af\u30cb\u30ab\u30eb\u306a\u5b9f\u88c5\u304c\u306a\u304f\u306a\u3063\u3066\u3001\u7d20\u76f4\u306a\u5b9f\u88c5\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001\uff08\u5f53\u305f\u308a\u524d\u3067\u3059\u304c\uff09 v6.0.0-beta.1 \u3067\u3082 <code>render()<\/code> \u306e\u547c\u3070\u308c\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u306f\u5909\u308f\u3063\u3066\u3044\u306a\u3044\u3088\u3046\u3067\u3059\u3002<\/p>\n<div align=\"right\"><a href=\"https:\/\/codepen.io\/higashi-masaru\/pen\/mQBBPV\">Try it on CodePen<\/a><\/div>\n<h2 id=\"conclusions\">\u307e\u3068\u3081<\/h2>\n<p>\u5404\u7a2e\u72b6\u614b\u7ba1\u7406\u65b9\u6cd5\u306e\u30d1\u30bf\u30fc\u30f3\u3054\u3068\u306b <code>render()<\/code> \u304c\u3069\u306e\u3088\u3046\u306b\u547c\u3070\u308c\u308b\u304b\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8003\u3048\u308b\u3068 <code>render()<\/code> \u306e\u52d5\u4f5c\u304c\u7406\u89e3\u3057\u3084\u3059\u3044\u3067\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" >const App = () =&gt; (\n  &lt;Something&gt;\n    &lt;A \/&gt;\n  &lt;\/Something&gt;\n);\n<\/pre>\n<ul>\n<li>App \u3068 A \u306f\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u4e0a\u4e0b\u95a2\u4fc2<\/li>\n<ul>\n<li>App \u306e State \u304c\u5909\u66f4\u3055\u308c\u308b\u3068\u3001 A \u306e `render()` \u304c\u547c\u3070\u308c\u308b<\/li>\n<\/ul>\n<li>Something \u3068 A \u306f JSX \u5185\u306e DOM \u7684\u306a\u4e0a\u4e0b\u95a2\u4fc2<\/li>\n<ul>\n<li>Something \u306e State \u304c\u5909\u66f4\u3055\u308c\u3066\u3082\u3001 A \u306e `render()` \u306f\u547c\u3070\u308c\u306a\u3044<\/li>\n<\/ul>\n<\/ul>\n<p>PureComponent \u3092\u4f7f\u3046\u306e\u304c\u738b\u9053\u306a\u306e\u3067\u3059\u304c\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u4e0a\u4e0b\u95a2\u4fc2\u306b\u6ce8\u76ee\u3057\u3066 <code>render()<\/code> \u304c\u3044\u3064\u547c\u3070\u308c\u308b\u306e\u304b\u3092\u628a\u63e1\u3057\u3066\u304a\u304f\u306e\u304c\u3088\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>Enjoy your <span style=\"\ncolor: #61dafb;\nfont-size: 120%;\nfont-weight: 700;\nfont-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;\n-webkit-font-smoothing: antialiased;\nletter-spacing: 0.01em;\n\">React<\/span> life!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u308c\u306f TECHSCORE Advent Calendar 2018 \u306e\uff12\u65e5\u76ee\u306e\u8a18\u4e8b\u3067\u3059\u3002<br \/>\nReact \u3067\u7121\u90aa\u6c17\u306b\u958b\u767a\u3092\u3057\u3066\u3044\u308b\u3068\u3001\u3084\u305f\u3089\u3068 render() \u304c\u547c\u3070\u308c\u308b\u306e\u304c\u6c17\u306b\u306a\u308a\u307e\u3059\u3002<br \/><a href=\"https:\/\/www.techscore.com\/blog\/2018\/12\/02\/react-when-the-render-will-be-called\/\">\u7d9a\u304d\u3092\u8aad\u3080...<\/a><\/p>\n","protected":false},"author":44,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[308,18],"tags":[141,275],"_links":{"self":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/18974"}],"collection":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/users\/44"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/comments?post=18974"}],"version-history":[{"count":169,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/18974\/revisions"}],"predecessor-version":[{"id":19340,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/18974\/revisions\/19340"}],"wp:attachment":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/media?parent=18974"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/categories?post=18974"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/tags?post=18974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}