chore: remove swr and dead code (#3495)

This commit is contained in:
Oxylibrium
2022-08-12 15:06:40 -04:00
committed by GitHub
parent 010f64e8e9
commit 0a46b1e59d
5 changed files with 9 additions and 53 deletions
-1
View File
@@ -49,7 +49,6 @@
"react-markdown": "8.0.3",
"react-router-dom": "6.3.0",
"sourcemapped-stacktrace": "1.1.11",
"swr": "1.2.2",
"tzdata": "1.0.30",
"uuid": "8.3.2",
"xstate": "4.32.1",
+9 -29
View File
@@ -2,7 +2,6 @@ import CssBaseline from "@material-ui/core/CssBaseline"
import ThemeProvider from "@material-ui/styles/ThemeProvider"
import { FC } from "react"
import { BrowserRouter as Router } from "react-router-dom"
import { SWRConfig } from "swr"
import { AppRouter } from "./AppRouter"
import { ErrorBoundary } from "./components/ErrorBoundary/ErrorBoundary"
import { GlobalSnackbar } from "./components/GlobalSnackbar/GlobalSnackbar"
@@ -13,34 +12,15 @@ import { XServiceProvider } from "./xServices/StateContext"
export const App: FC = () => {
return (
<Router>
<SWRConfig
value={{
// This code came from the SWR documentation:
// https://swr.vercel.app/docs/error-handling#status-code-and-error-object
fetcher: async (url: string) => {
const res = await fetch(url)
// By default, `fetch` won't treat 4xx or 5xx response as errors.
// However, we want SWR to treat these as errors - so if `res.ok` is false,
// we want to throw an error to bubble that up to SWR.
if (!res.ok) {
const err = new Error((await res.json()).error?.message || res.statusText)
throw err
}
return res.json()
},
}}
>
<ThemeProvider theme={dark}>
<CssBaseline />
<ErrorBoundary>
<XServiceProvider>
<AppRouter />
<GlobalSnackbar />
</XServiceProvider>
</ErrorBoundary>
</ThemeProvider>
</SWRConfig>
<ThemeProvider theme={dark}>
<CssBaseline />
<ErrorBoundary>
<XServiceProvider>
<AppRouter />
<GlobalSnackbar />
</XServiceProvider>
</ErrorBoundary>
</ThemeProvider>
</Router>
)
}
-1
View File
@@ -1,2 +1 @@
export * from "./array"
export * from "./swr"
-17
View File
@@ -1,17 +0,0 @@
/**
* unsafeSWRArgument
*
* Helper function for working with SWR / useSWR in the TypeScript world.
* TypeScript is helpful in enforcing type-safety, but SWR is designed to
* with the expectation that, if the argument is not available, an exception
* will be thrown.
*
* This just helps in abiding by those rules, explicitly, and lets us suppress
* the lint warning in a single place.
*/
export const unsafeSWRArgument = <T>(arg: T | null | undefined): T => {
if (typeof arg === "undefined" || arg === null) {
throw "SWR: Expected exception because the argument is not available"
}
return arg
}
-5
View File
@@ -13113,11 +13113,6 @@ svgo@^2.7.0:
picocolors "^1.0.0"
stable "^0.1.8"
swr@1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/swr/-/swr-1.2.2.tgz#6cae09928d30593a7980d80f85823e57468fac5d"
integrity sha512-ky0BskS/V47GpW8d6RU7CPsr6J8cr7mQD6+do5eky3bM0IyJaoi3vO8UhvrzJaObuTlGhPl2szodeB2dUd76Xw==
symbol-tree@^3.2.4:
version "3.2.4"
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2"