fix(striker-ui): upgrade swr from 0.5.7->1.2.2

There's a bug where the onSuccess property of SWRConfiguration
causes a crashed when it is undefined. Seems to be fixed in later
versions, so doing a simple upgrade patches the problem.

This issue caused the Dashboard to show nothing.
main
Tsu-ba-me 3 years ago
parent 012a1828f8
commit 0c41c45903
  1. 8
      striker-ui/lib/fetchers/periodicFetch.ts
  2. 36
      striker-ui/package-lock.json
  3. 2
      striker-ui/package.json
  4. 6
      striker-ui/types/GetResponse.d.ts

@ -5,20 +5,20 @@ import fetcher from './fetchJSON';
const periodicFetch = <T>(
url: string,
{ refreshInterval = 5000, onSuccess }: SWRConfiguration = {},
): GetResponses => {
): GetResponses<T> => {
// The purpose of react-hooks/rules-of-hooks is to ensure that react hooks
// are called in order (i.e., not potentially skipped due to conditionals).
// We can safely disable this rule as this function is simply a wrapper.
// eslint-disable-next-line react-hooks/rules-of-hooks
const { data, error } = useSWR<T>(url, fetcher, {
const { data, error: swrError } = useSWR<T>(url, fetcher, {
refreshInterval,
onSuccess,
});
return {
data,
isLoading: !error && !data,
isError: error,
isLoading: !swrError && !data,
error: swrError,
};
};

@ -24,7 +24,7 @@
"pretty-bytes": "^5.6.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"swr": "^0.5.6",
"swr": "^1.2.2",
"uuid": "^8.3.2"
},
"devDependencies": {
@ -2359,14 +2359,6 @@
"node": ">= 0.4"
}
},
"node_modules/dequal": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.2.tgz",
"integrity": "sha512-q9K8BlJVxK7hQYqa6XISGmBZbtQQWVXSrRrWreHC94rMt1QL/Impruc+7p2CYSYuVIUr+YCt6hjrs1kkdJRTug==",
"engines": {
"node": ">=6"
}
},
"node_modules/dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
@ -5818,14 +5810,11 @@
}
},
"node_modules/swr": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/swr/-/swr-0.5.7.tgz",
"integrity": "sha512-Jh1Efgu8nWZV9rU4VLUMzBzcwaZgi4znqbVXvAtUy/0JzSiN6bNjLaJK8vhY/Rtp7a83dosz5YuehfBNwC/ZoQ==",
"dependencies": {
"dequal": "2.0.2"
},
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/swr/-/swr-1.2.2.tgz",
"integrity": "sha512-ky0BskS/V47GpW8d6RU7CPsr6J8cr7mQD6+do5eky3bM0IyJaoi3vO8UhvrzJaObuTlGhPl2szodeB2dUd76Xw==",
"peerDependencies": {
"react": "^16.11.0 || ^17.0.0"
"react": "^16.11.0 || ^17.0.0 || ^18.0.0"
}
},
"node_modules/table": {
@ -7904,11 +7893,6 @@
"object-keys": "^1.0.12"
}
},
"dequal": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.2.tgz",
"integrity": "sha512-q9K8BlJVxK7hQYqa6XISGmBZbtQQWVXSrRrWreHC94rMt1QL/Impruc+7p2CYSYuVIUr+YCt6hjrs1kkdJRTug=="
},
"dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
@ -10471,12 +10455,10 @@
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w=="
},
"swr": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/swr/-/swr-0.5.7.tgz",
"integrity": "sha512-Jh1Efgu8nWZV9rU4VLUMzBzcwaZgi4znqbVXvAtUy/0JzSiN6bNjLaJK8vhY/Rtp7a83dosz5YuehfBNwC/ZoQ==",
"requires": {
"dequal": "2.0.2"
}
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/swr/-/swr-1.2.2.tgz",
"integrity": "sha512-ky0BskS/V47GpW8d6RU7CPsr6J8cr7mQD6+do5eky3bM0IyJaoi3vO8UhvrzJaObuTlGhPl2szodeB2dUd76Xw==",
"requires": {}
},
"table": {
"version": "6.8.0",

@ -29,7 +29,7 @@
"pretty-bytes": "^5.6.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"swr": "^0.5.6",
"swr": "^1.2.2",
"uuid": "^8.3.2"
},
"devDependencies": {

@ -1,5 +1,5 @@
declare type GetResponses = {
data: T;
declare type GetResponses<T> = {
data: T | undefined;
error: Error | undefined;
isLoading: boolean;
isError: Error;
};

Loading…
Cancel
Save