diff --git a/package-lock.json b/package-lock.json index de60774..02b1baa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "vite-react-stream-utils", "version": "0.0.0", "dependencies": { + "@tanstack/react-query": "^5.56.2", "react": "^18.3.1", "react-dom": "^18.3.1" }, @@ -1284,6 +1285,32 @@ "win32" ] }, + "node_modules/@tanstack/query-core": { + "version": "5.56.2", + "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.56.2.tgz", + "integrity": "sha512-gor0RI3/R5rVV3gXfddh1MM+hgl0Z4G7tj6Xxpq6p2I03NGPaJ8dITY9Gz05zYYb/EJq9vPas/T4wn9EaDPd4Q==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/react-query": { + "version": "5.56.2", + "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.56.2.tgz", + "integrity": "sha512-SR0GzHVo6yzhN72pnRhkEFRAHMsUo5ZPzAxfTMvUxFIDVS6W9LYUp6nXW3fcHVdg0ZJl8opSH85jqahvm6DSVg==", + "license": "MIT", + "dependencies": { + "@tanstack/query-core": "5.56.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": "^18 || ^19" + } + }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", diff --git a/package.json b/package.json index f9aa889..cc3e064 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "preview": "vite preview" }, "dependencies": { + "@tanstack/react-query": "^5.56.2", "react": "^18.3.1", "react-dom": "^18.3.1" }, diff --git a/src/App.tsx b/src/App.tsx index f535ef3..f34c74e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,10 +1,18 @@ -import { useContext } from "react"; +import { useContext, useMemo } from "react"; import { AuthStateContext } from "./contexts/auth-state/AuthStateContext"; import LoginButton from "./components/LoginButton"; import Chat from "./components/Chat"; +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; export default function App() { const authContext = useContext(AuthStateContext); + const queryClient = useMemo( + () => + new QueryClient({ + defaultOptions: { queries: { staleTime: Infinity } }, + }), + [] + ); if (!authContext) { return
Missing AuthStateContext provider?
; @@ -12,18 +20,20 @@ export default function App() { return ( <> -- Hello: {authContext.authState.user.login} -
-+ Hello: {authContext.authState.user.login} +
+{pronoun}
; + return{pronoun.data}
; } diff --git a/src/hooks/usePronouns.ts b/src/hooks/usePronouns.ts index f42cab0..10086b0 100644 --- a/src/hooks/usePronouns.ts +++ b/src/hooks/usePronouns.ts @@ -1,4 +1,4 @@ -import { useEffect, useMemo, useState } from "react"; +import { useQuery } from "@tanstack/react-query"; const PRONOUNS_URL = "https://api.pronouns.alejo.io/v1"; @@ -18,36 +18,27 @@ interface UserEntry { type PronounResponse = Record