{"id":13537,"date":"2021-06-05T10:57:55","date_gmt":"2021-06-05T01:57:55","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=13537"},"modified":"2023-09-23T10:18:43","modified_gmt":"2023-09-23T01:18:43","slug":"%e3%80%90react%e3%80%91%e3%80%8creact-query%e3%80%8d%e3%81%ae%e5%b0%8e%e5%85%a5","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=13537","title":{"rendered":"\u3010React\u3011\u300cReact Query\u300d\u306e\u300cuseQuery\u300d\u3001\u30b9\u30c6\u30fc\u30bf\u30b9\u306b\u3064\u3044\u3066"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n\n\n\n<p>react-qurery\u3068devtools\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304f\u3068\u4fbf\u5229\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">npm install react-query\nnpm install react-query-devtools<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">react-query-devtools<\/h3>\n\n\n\n<p>\u5c0e\u5165\u3059\u308b\u3068\u30d6\u30e9\u30a6\u30b6\u5de6\u4e0b\u3067\u30c7\u30d0\u30c3\u30ac\u30fc\u306e\u3088\u3046\u306a\u3082\u306e\u304c\u51fa\u307e\u3059\u3002React-Query\u3067\u958b\u767a\u3057\u3066\u3044\u304f\u306e\u3067\u3042\u308c\u3070\u975e\u5e38\u306b\u4fbf\u5229\u306a\u30c4\u30fc\u30eb\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">App.tsx\u3078\u306e\u5c0e\u5165<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">import { VFC } from 'react'\nimport { QueryClient, QueryClientProvider } from 'react-query'\nimport { ReactQueryDevtools } from 'react-query\/devtools'\nimport { BrowserRouter, Route, Switch } from 'react-router-dom'\nimport { ReactQuery\u3092\u5c0e\u5165\u3059\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u540d } from '.\/components\/ReactQuery\u3092\u5c0e\u5165\u3059\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u540d'\n\nconst queryClient = new QueryClient({\n  defaultOptions: {\n    queries: {\n      retry: false,\n      refetchOnWindowFocus: false,\n      suspense: true, \/\/ React18\u304b\u3089\u306e\u6a5f\u80fd\u306a\u306e\u3067\u6ce8\u610f\n    },\n  },\n})\n\nconst App: VFC = () =&gt; {\n  return (\n    &lt;QueryClientProvider client={queryClient}&gt;\n      &lt;BrowserRouter&gt;\n            &lt;Switch&gt;\n              &lt;Route exact path=\"\/\"&gt;\n                &lt;ReactQuery\u3092\u5c0e\u5165\u3059\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u540d \/&gt;\n              &lt;\/Route&gt;\n            &lt;\/Switch&gt;\n      &lt;\/BrowserRouter&gt;\n      &lt;ReactQueryDevtools initialIsOpen={false} \/&gt;\n    &lt;\/QueryClientProvider&gt;\n  )\n}\n\nexport default App\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">QueryClient<\/h3>\n\n\n\n<p>\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u3044\u304f\u3064\u304b\u8a2d\u5b9a\u3067\u304d\u307e\u3059\u3002\u3053\u3053\u3067\u9069\u7528\u3057\u305f\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5185\u306e\u5168\u3066\u306eQuery\u306b\u9069\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>\u30aa\u30d7\u30b7\u30e7\u30f3\u540d<\/th><th>\u8aac\u660e<\/th><\/tr><tr><td>retry<\/td><td>\u30c7\u30d5\u30a9\u30eb\u30c8\u30673\u56de\u307e\u3067\u5931\u6557\u3057\u3066\u3082\u30d5\u30a7\u30c3\u30c1\u3092\u3059\u308b\u8a2d\u5b9a\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u304c\u3001false\u3092\u6307\u5b9a\u3059\u308c\u3070\u7121\u52b9\u5316\u3067\u304d\u307e\u3059\u3002<\/td><\/tr><tr><td>refetchOnWindowFocus<\/td><td>\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u30e6\u30fc\u30b6\u30fc\u304c\u30d6\u30e9\u30a6\u30b6\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u30d5\u30a9\u30fc\u30ab\u30b9\u3092\u5f53\u3066\u305f\u6642\u306b\u81ea\u52d5\u3067\u30d5\u30a7\u30c3\u30c1\u304c\u52d5\u304f\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u304c\u591a\u304f\u884c\u308f\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u304b\u306d\u306a\u3044\u306e\u3067\u3001\u3067\u304d\u308c\u3070false\u306b\u3057\u3066\u304a\u304f\u306e\u304c\u671b\u307e\u3057\u3044\u3067\u3057\u3087\u3046\u3002<\/td><\/tr><tr><td>suspense<\/td><td>React18\u304b\u3089\u306e\u6a5f\u80fd\u3067\u3059\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">&lt;ReactQueryDevtools initialIsOpen={false} \/&gt;<\/h3>\n\n\n\n<p>ReactQuery\u306edevtool\u3092\u6709\u52b9\u5316\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">InitialsOpen<\/h4>\n\n\n\n<p>true\u3060\u3068\u30d6\u30e9\u30a6\u30b6\u3092\u958b\u3044\u305f\u6642\u306b\u81ea\u52d5\u3067\u8d77\u52d5\u3057\u307e\u3059\u3002false\u3060\u3068\u9589\u3058\u305f\u72b6\u614b\u306b\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30ab\u30b9\u30bf\u30e0\u30d5\u30c3\u30af\u306e\u8a18\u8ff0\u65b9\u6cd5<\/h2>\n\n\n\n<p>useQuery\u7528\u306e\u30ab\u30b9\u30bf\u30e0\u30d5\u30c3\u30af\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<span style=\"color: #ff0000;\"><strong>useQuery<\/strong><\/span>\u3068\u3044\u3046\u30d5\u30c3\u30af\u3092\u4f7f\u3063\u3066API\u304b\u3089\u306efetch\u3092\u884c\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u306a\u304a\u3001useQuery\u304c\u52d5\u304f\u30bf\u30a4\u30df\u30f3\u30b0\u3068\u3057\u3066\u306f\u5f8c\u8ff0\u3059\u308b<span style=\"color: #ff0000;\"><strong>\u547c\u3073\u51fa\u3059\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304c\u30de\u30a6\u30f3\u30c8\u3055\u308c\u305f\u30bf\u30a4\u30df\u30f3\u30b0<\/strong><\/span>\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import { useQuery } from 'react-query'\nimport axios from 'axios'\n\nconst getXXX = async () =&gt; {\n  const { data } = await axios.get&lt;\u30d5\u30a7\u30c3\u30c1\u3059\u308b\u30c7\u30fc\u30bf\u306e\u30c7\u30fc\u30bf\u578b[]&gt;('API\u306eURL')\n  return data\n}\n\nexport const useQueryXXX = () =&gt; {\n  return useQuery&lt;\u30d5\u30a7\u30c3\u30c1\u3059\u308b\u30c7\u30fc\u30bf\u306e\u30c7\u30fc\u30bf\u578b[], Error&gt;({\n    queryKey: 'xxx',\n    queryFn: getXXX,\n    cacheTime: 10000,\n    staleTime: 0,\n  })\n}<\/pre>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>\u5f15\u6570<\/th><th>\u8aac\u660e<\/th><\/tr><tr><td>queryKey<\/td><td>ReactQuery\u306e\u30ad\u30fc\u3067\u3059\u3002\u597d\u304d\u306a\u540d\u524d\u3092\u3064\u3051\u308c\u307e\u3059\u3002\uff08\u4f8b\uff1aTasks\u306a\u3069\uff09<\/td><\/tr><tr><td>queryFn<\/td><td>\u975e\u540c\u671f\u306e\u95a2\u6570\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/td><\/tr><tr><td>cacheTime<\/td><td>\u30df\u30ea\u79d2\u306e\u5358\u4f4d\u3067\u6307\u5b9a\u3057\u307e\u3059\u3002useQuery\u3057\u3066\u3044\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304c\u30a2\u30f3\u30de\u30a6\u30f3\u30c8\u3055\u308c\u305f\u5834\u5408\u306b\u6307\u5b9a\u3057\u305f\u6642\u9593\u7d4c\u904e\u5f8c\u306b\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u524a\u9664\u3055\u308c\u308b\u6319\u52d5\u306b\u306a\u308a\u307e\u3059\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u30675\u5206\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306f\u7279\u5225\u306a\u7406\u7531\u304c\u306a\u3051\u308c\u3070\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u5024\u3067\u554f\u984c\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u6307\u5b9a\u3092\u3057\u306a\u304f\u3066\u3082\u826f\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<br>\u30ac\u30d9\u30fc\u30b8\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3067\u4e0d\u8981\u306a\u30e1\u30e2\u30ea\u3092\u524a\u9664\u3057\u3066\u304f\u308c\u308b\u3068\u3044\u3046\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308a\u307e\u3059\u3002<\/td><\/tr><tr><td>staleTime<\/td><td>\u30df\u30ea\u79d2\u306e\u5358\u4f4d\u3067\u6307\u5b9a\u3057\u307e\u3059\u3002\u4f8b\u3048\u3070\u300110000\u3092\u6307\u5b9a\u3057\u305f\u5834\u5408\u306f10\u79d2\u306b\u306a\u308a\u307e\u3059\u3002\u6307\u5b9a\u3057\u305f\u6642\u9593\u7d4c\u904e\u5f8c\u306b\u30b5\u30fc\u30d0\u30fc\u306b\u518d\u5ea6fetch\u3092\u884c\u3046\u6319\u52d5\u306b\u306a\u308a\u307e\u3059\u3002<br>3\u307e\u3067\u306f\u81ea\u52d5\u518d\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u304c\u884c\u308f\u308c\u308b\u4ed5\u69d8\u3067\u3057\u305f\u304c\u30014\u304b\u3089\u306f\u81ea\u52d5\u3067\u306f\u306a\u304f\u306a\u308a\u307e\u3057\u305f\u3002<\/td><\/tr><tr><td>\n<div>\n<div>refetchOnWindowFocus<\/div>\n<\/div>\n<\/td><td>\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u30e6\u30fc\u30b6\u30fc\u304c\u30d6\u30e9\u30a6\u30b6\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u30d5\u30a9\u30fc\u30ab\u30b9\u3092\u5f53\u3066\u305f\u6642\u306b\u81ea\u52d5\u3067\u30d5\u30a7\u30c3\u30c1\u304c\u52d5\u304f\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u304c\u591a\u304f\u884c\u308f\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u304b\u306d\u306a\u3044\u306e\u3067\u3001\u3067\u304d\u308c\u3070false\u306b\u3057\u3066\u304a\u304f\u306e\u304c\u671b\u307e\u3057\u3044\u3067\u3057\u3087\u3046\u3002<\/td><\/tr><tr><td>refetchInterval<\/td><td>\u518d\u30d5\u30a7\u30c3\u30c1\u3057\u305f\u3044\u5834\u5408\u306e\u79d2\u6570\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u81ea\u52d5\u3067\u305d\u306e\u79d2\u6570\u5f8c\u30d5\u30a7\u30c3\u30c1\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">staleTime<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Infinity<\/h4>\n\n\n\n<p>\u81ea\u5206\u3001\u3082\u3057\u304f\u306f\u4ed6\u4eba\u306e\u8ab0\u304b\u304c\u66f4\u65b0\u3057\u305f\u30c7\u30fc\u30bf\u304c\u5f71\u97ff\u3057\u3042\u3046\u53ef\u80fd\u6027\u304c\u306a\u3044\u5834\u5408\u306f\u3053\u308c\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u7121\u9650\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u3001\u4e00\u5b9a\u9593\u9694\u3067\u30b5\u30fc\u30d0\u30fc\u306b\u30c7\u30fc\u30bf\u3092fetch\u3059\u308b\u3053\u3068\u3092\u9632\u6b62\u3057\u307e\u3059\u3002\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306a\u3069\u3067\u306f\u3053\u306e\u8a2d\u5b9a\u3067\u3082\u826f\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<p>fetch\u3059\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u3068\u3057\u3066\u306f\u3001\u521d\u671f\u8868\u793a\u6642\u3082\u3057\u304f\u306f\u81ea\u5206\u3067\u30c7\u30fc\u30bf\u3092\u66f4\u65b0\u3057\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u306e\u3069\u3061\u3089\u304b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u547c\u3073\u51fa\u3059\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u5074<\/h2>\n\n\n\n<p>reactQuery\u3067\u7d50\u679c\u3092\u547c\u3073\u51fa\u3059\u5074\u3067\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import { useQueryXXX } from '..\/useQueryXXX'\n\nexport const \u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u540d: VFC = () =&gt; {\n  const { status, data } = useQueryXXX()\n  return (\n    &lt;&gt;\n      {data}\n    &lt;\/&gt;\n  )\n}<\/pre>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>\u623b\u308a\u5024<\/th><th>\u8aac\u660e<\/th><\/tr><tr><td>status<\/td><td>\u901a\u4fe1\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u304c\u5165\u308a\u307e\u3059\u3002\u306a\u304a\u3001\u3053\u306e\u4e2d\u306bloading\u3084error\u306a\u3069\u3082\u6301\u3063\u3066\u304a\u308a\u3001\u4f59\u5206\u306auseState\u3092\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u5074\u306b\u6301\u305f\u305b\u308b\u5fc5\u8981\u304c\u306a\u304f\u306a\u308b\u306e\u3067\u518d\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u306e\u5bfe\u7b56\u306b\u3082\u306a\u308a\u307e\u3059\u3002<\/td><\/tr><tr><td>data<\/td><td>fetch\u3057\u305f\u30c7\u30fc\u30bf\u304c\u5165\u308a\u307e\u3059\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u30ad\u30e3\u30c3\u30b7\u30e5\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u66f8\u304d\u65b9\uff08getQueryData\uff09<\/h2>\n\n\n\n<p>useQuery\u3067\u30c7\u30fc\u30bf\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u3057\u307e\u3059\u304c\u3001\u30ad\u30e3\u30c3\u30b7\u30e5\u3057\u305f\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import { VFC } from 'react'\nimport { useQueryClient } from 'react-query'\n\nexport const ReactQueryB: VFC = () =&gt; {\n  const queryClient = useQueryClient()\n  const data = queryClient.getQueryData&lt;\u30d5\u30a7\u30c3\u30c1\u3059\u308b\u30c7\u30fc\u30bf\u578b[]&gt;('queryKey\u3092\u6307\u5b9a')\n  return (\n    &lt;&gt;\n      {data}\n    &lt;\/&gt;\n  )\n}\u306a<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">getQueryData\u306e\u6ce8\u610f\u70b9<\/h3>\n\n\n\n<p>\u306a\u304a\u3001useQuery\u3067fetch\u3059\u308b\u5834\u5408\u306b\u6bd4\u3079\u3066getQueryData\u306b\u3088\u308b\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u53d6\u5f97\u306f\u6700\u65b0\u30c7\u30fc\u30bf\u3092\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u306b\u66f4\u65b0\u3059\u308b\u3068\u3053\u308d\u307e\u3067\u306f\u3084\u3063\u3066\u304f\u308c\u306a\u3044\u306e\u3067\u6ce8\u610f\u3067\u3059\u3002useQuery\u306f\u6bce\u56de\u30ad\u30e3\u30c3\u30b7\u30e5\u306b\u5909\u66f4\u304c\u3042\u308b\u304b\u691c\u77e5\u3057\u3066\u518d\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u306a\u306e\u3067\u3001\u4f7f\u3044\u6240\u3068\u3057\u3066\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u30c7\u30fc\u30bf\u767b\u9332API\u5b9f\u884c\u5f8c\u306e\u518d\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3059\u308b\u969b\u306e\u4e8b\u524d\u30c7\u30fc\u30bf\u53d6\u5f97\u51e6\u7406\u306a\u3069\u306b\u9650\u3089\u308c\u307e\u3059\u3002<\/strong><\/span><\/p>\n\n\n\n<p>\u901a\u5e38\u306e\u8868\u793a\u51e6\u7406\u306a\u3069\u3067\u306fgetQueryData\u3067\u306f\u306a\u304fuseQuery\u3092\u4f7f\u7528\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b9\u30c6\u30fc\u30bf\u30b9\u3092\u95b2\u89a7\u3067\u304d\u308b\u30c4\u30fc\u30eb<\/h2>\n\n\n\n<p>\u300cReactQueryDevtools\u300d\u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3048\u3070\u3001React Query\u306b\u3088\u3063\u3066\u4eca\u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u304c\u3069\u306e\u3088\u3046\u306a\u30b9\u30c6\u30fc\u30bf\u30b9\u306b\u306a\u3063\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305f\u3001\u3053\u306e\u30c4\u30fc\u30eb\u3092\u4f7f\u3048\u3070\u3001React Query\u3067\u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u306e\u4e00\u89a7\u3082\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">React Query\u306e\u30b9\u30c6\u30fc\u30bf\u30b9<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">fresh<\/h3>\n\n\n\n<p>\u6700\u65b0\u306e\u30c7\u30fc\u30bf\u3068\u307f\u306a\u3059\u3002\u3053\u306e\u72b6\u614b\u306e\u969b\u306f\u3001\u4f55\u5ea6\u30ea\u30af\u30a8\u30b9\u30c8\u3057\u305f\u3068\u3057\u3066\u3082\u30ad\u30e3\u30c3\u30b7\u30e5\u30c7\u30fc\u30bf\u304c\u4f7f\u308f\u308c\u3066\u30b5\u30fc\u30d0\u30fc\u3078\u306e\u30d5\u30a7\u30c3\u30c1\u304c\u884c\u308f\u308c\u307e\u305b\u3093\u3002staleTime\u3067\u6307\u5b9a\u3057\u305f\u79d2\u6570\u7d4c\u904e\u3057\u305f\u3089fresh\u2192stale\u3068\u3044\u3046\u72b6\u614b\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">fetching<\/h3>\n\n\n\n<p>\u30b5\u30fc\u30d0\u30fc\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u4e2d\u306e\u72b6\u614b\u3067\u3059\u3002\u901a\u5e38\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u901f\u5ea6\u3060\u3068\u4e00\u77ac\u3057\u304b\u8868\u793a\u3055\u308c\u306a\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">stale<\/h3>\n\n\n\n<p>\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u53e4\u3044\u7269\u3060\u3068\u307f\u306a\u3057\u3066\u3044\u308b\u72b6\u614b\u306e\u3053\u3068\u3067\u3059\u3002staleTime\u3067\u6307\u5b9a\u3057\u305f\u6642\u9593\u304c\u7d4c\u904e\u3057\u305f\u5f8c\u306b\u3053\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u306b\u79fb\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u306a\u304a\u3001\u4eee\u306bstaleTime\u304c\u7d4c\u904e\u3057\u3066\u3044\u305f\u3068\u3057\u3066\u3082\u4e00\u65e6\u3053\u3061\u3089\u306e\u30c7\u30fc\u30bf\u3092\u753b\u9762\u306b\u8868\u793a\u3055\u305b\u307e\u3059\u3002\u305d\u306e\u5f8c\u3001REST API\u306e\u65b9\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3066\u518d\u63cf\u753b\u304c\u884c\u308f\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Inactive<\/h3>\n\n\n\n<p><span style=\"color: #ff0000;\"><strong>\u30ad\u30e3\u30c3\u30b7\u30e5\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3066\u3044\u308b\u72b6\u614b<\/strong><\/span>\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb react-qurery\u3068devtools\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304f\u3068\u4fbf\u5229\u3067\u3059\u3002 npm install react-query npm install react-query-devtools react-q [&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\/13537"}],"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=13537"}],"version-history":[{"count":35,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/13537\/revisions"}],"predecessor-version":[{"id":23112,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/13537\/revisions\/23112"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13537"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13537"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13537"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}