{"id":13520,"date":"2021-05-30T11:06:11","date_gmt":"2021-05-30T02:06:11","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=13520"},"modified":"2023-09-23T09:20:16","modified_gmt":"2023-09-23T00:20:16","slug":"%e3%80%90react%e3%80%91%e3%80%8creact-query%e3%80%8d%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=13520","title":{"rendered":"\u3010React\u3011\u300cReact Query\u300d\u306b\u3064\u3044\u3066"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">React Query\u3068\u306f\uff1f<\/h2>\n\n\n\n<p>2020\u5e742\u6708\u306b\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30ea\u30ea\u30fc\u30b9\u30ce\u30fc\u30c8<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>\u30d0\u30fc\u30b8\u30e7\u30f3<\/th><th>\u30ea\u30ea\u30fc\u30b9\u65e5<\/th><th>\u8aac\u660e<\/th><\/tr><tr><td><\/td><td><\/td><td><\/td><\/tr><tr><td><\/td><td><\/td><td><\/td><\/tr><tr><td>3<\/td><td><\/td><td><\/td><\/tr><tr><td>4<\/td><td>2022\/4<\/td><td>React18\u306b\u5bfe\u5fdc\u3057\u305f\u3002suspense\u306a\u3069\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u5b9f\u88c5\u304c\u5897\u3048\u3066\u307e\u3059\u3002<\/td><\/tr><tr><td><\/td><td><\/td><td><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">SWR<\/h2>\n\n\n\n<p>\u540c\u7cfb\u7d71\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u3057\u3066SWR\u304c\u3042\u308a\u307e\u3059\u3002React Query\u3068\u6bd4\u8f03\u3059\u308b\u3068SWR\u306e\u65b9\u304c\u30b7\u30f3\u30d7\u30eb\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u306a\u3063\u3066\u3044\u3066\u8efd\u91cf\u3067\u3059\u3002\u306a\u306e\u3067\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u7279\u6027\u306b\u5408\u308f\u305b\u3066React Query\u304bSWR\u3069\u3061\u3089\u3092\u4f7f\u3046\u304b\u3092\u691c\u8a0e\u3057\u3066\u3044\u304f\u3068\u826f\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30e1\u30ea\u30c3\u30c8<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">fetch\u306e\u56de\u6570\u3092\u6e1b\u3089\u305b\u308b\u3002<\/h3>\n\n\n\n<p>\u30b5\u30fc\u30d0\u30fc\u304b\u3089\u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u306b\u683c\u7d0d\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u3001\u4e0d\u8981\u306aAPI fetch\u306e\u56de\u6570\u3092\u6e1b\u3089\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305fuseContext\u3084Redux\u3067\u306f\u3067\u304d\u306a\u304b\u3063\u305f\u3002<\/p>\n\n\n\n<p>\u5f93\u6765\u3060\u3068useEffect\u3067\u7b2c\u4e8c\u5f15\u6570\u306b[]\u3092\u6307\u5b9a\u3057\u3066\u3044\u305f\u3068\u3057\u3066\u3082\u30de\u30a6\u30f3\u30c8\u3055\u308c\u308b\u5ea6\u306bfetch\u304c\u5b9f\u884c\u3055\u308c\u308b\u3002\u306a\u306e\u3067\u3001\u5225\u753b\u9762\u306b\u884c\u3063\u3066\u623b\u3063\u3066\u304d\u305f\u3068\u3057\u3066\u3082\u6539\u3081\u3066fetch\u304c\u5b9f\u884c\u3055\u308c\u305f\u308a\u3059\u308b\u3002React Query\u306fstaleTime\u306b\u3088\u3063\u3066\u518dfetch\u306e\u9593\u9694\u3092\u5236\u5fa1\u3067\u304d\u305f\u308a\u3059\u308b\u3002<\/p>\n\n\n\n<p>\u307e\u305f\u3001\u30ad\u30e3\u30c3\u30b7\u30e5\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u306fLoading\u304c\u8868\u793a\u3055\u308c\u305a\u3059\u3050\u306b\u30c7\u30fc\u30bf\u3092\u95b2\u89a7\u3067\u304d\u308b\u30e1\u30ea\u30c3\u30c8\u3082\u3042\u308b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Redux\u306b\u683c\u7d0d\u3059\u308b\u30c7\u30fc\u30bf\u91cf\u3092\u6e1b\u3089\u305b\u308b\u3002<\/h3>\n\n\n\n<p>React Query\u306b\u3088\u308afetch\u3057\u3066\u30ad\u30e3\u30c3\u30b7\u30e5\u306b\u683c\u7d0d\u3055\u308c\u305f\u30c7\u30fc\u30bf\u306f<span style=\"color: #ff0000;\"><strong>\u81ea\u52d5\u7684\u306b\u30b0\u30ed\u30fc\u30d0\u30eb\u30b9\u30c6\u30fc\u30c8<\/strong><\/span>\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u306a\u306e\u3067\u3001\u69d8\u3005\u306a\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304b\u3089\u81ea\u7531\u306b\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30b3\u30fc\u30c9\u91cf\u304c\u304b\u306a\u308a\u6e1b\u308b\u3002<\/h3>\n\n\n\n<p>\u5f93\u6765\u306euseContext\u3084Redux\u3092\u4f7f\u3063\u305f\u66f8\u304d\u65b9\u306b\u6bd4\u3079\u308b\u3068\u4e0b\u8a18\u306e\u51e6\u7406\u3092\u8a18\u8ff0\u3057\u306a\u304f\u3066\u3088\u304f\u30b3\u30fc\u30c9\u8a18\u8ff0\u91cf\u304c\u6e1b\u308b\u3002<\/p>\n\n\n\n<ul>\n<li>useEffect\u3067fetch\u3059\u308b\u51e6\u7406<\/li>\n\n\n\n<li>fetch\u72b6\u6cc1\u306e\u53d6\u5f97<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">staleTime<\/h2>\n\n\n\n<p>staletime(\u4f8b\u3048\u3070\u300110\u79d2)\u3068\u3044\u3046\u306e\u3092\u8a2d\u5b9a\u3057\u3066\u304a\u3044\u3066\u305d\u306e\u9593\u306b\u6539\u3081\u3066\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3068\u3057\u3066\u3082\u6539\u3081\u3066fetch\u306f\u884c\u308f\u305a\u306b\u30ad\u30e3\u30c3\u30b7\u30e5\u304b\u3089\u53d6\u5f97\u3059\u308b\u3002\u307e\u305f\u3001API\u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3054\u3068\u306b\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u306f\u53ef\u80fd\u3002<\/p>\n\n\n\n<p>\u306a\u306e\u3067\u3001\u4f8b\u3048\u3070\u30b5\u30fc\u30d0\u30fc\u30c7\u30fc\u30bf\u304c\u307b\u3068\u3093\u3069\u5909\u308f\u3089\u306a\u3044\u3088\u3046\u306aAPI\u306e\u5834\u5408\u306fstaleTime\u3092\u9577\u3081\u306b\u8a2d\u5b9a\u3057\u3066\u304a\u304f\u306a\u3069\u306e\u8a2d\u5b9a\u3092\u9078\u629e\u3057\u305f\u308a\u3059\u308b\u3002<\/p>\n\n\n\n<p>\u307e\u305f\u3001\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u30c7\u30fc\u30bf\u304c\u53e4\u3044\u53ef\u80fd\u6027\u3082\u3042\u308b\u304c\u3068\u308a\u3042\u3048\u305a\u53e4\u3044\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3066\u305d\u306e\u88cf\u3067\u6700\u65b0\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3066\u304f\u308c\u308b\u3002\uff08Loading\u304c\u8868\u793a\u3055\u308c\u306a\u3044\u3002\uff09<\/p>\n\n\n\n<p>\u306a\u304a\u3001stale\u306b\u5230\u9054\u3057\u305f\u3068\u3057\u3066\u3082react-Query\u306ev4\u4ee5\u964d\u306fReact\u306e\u518d\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u304c\u884c\u308f\u308c\u306a\u304f\u306a\u3063\u3066\u3044\u307e\u3059\u3002\uff08\u305d\u308c\u307e\u3067\u306f\u884c\u308f\u308c\u308b\u3002\uff09<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">useQuery<\/h2>\n\n\n\n<p>\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">useMutation\uff08\u30e6\u30fc\u30b9\u30df\u30e5\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\uff09<\/h2>\n\n\n\n<p>\u30c7\u30fc\u30bf\u767b\u9332\u3001\u524a\u9664\u3001\u66f4\u65b0\u3057\u305f\u3044\u5834\u5408\u306b\u4f7f\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"React Query\u3068\u306f\uff1f 2020\u5e742\u6708\u306b\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u305f\u3002 \u30ea\u30ea\u30fc\u30b9\u30ce\u30fc\u30c8 \u30d0\u30fc\u30b8\u30e7\u30f3 \u30ea\u30ea\u30fc\u30b9\u65e5 \u8aac\u660e 3 4 2022\/4 React18\u306b\u5bfe\u5fdc\u3057\u305f\u3002suspense\u306a\u3069\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u5b9f\u88c5\u304c\u5897\u3048\u3066\u307e\u3059\u3002 SWR  [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[116],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/13520"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13520"}],"version-history":[{"count":16,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/13520\/revisions"}],"predecessor-version":[{"id":23106,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/13520\/revisions\/23106"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13520"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}