-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove QueryClientProvider initialization from graz
- Loading branch information
1 parent
d31c02c
commit 5619f52
Showing
5 changed files
with
70 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "graz", | ||
"description": "React hooks for Cosmos", | ||
"version": "0.1.29", | ||
"version": "0.2.0", | ||
"author": "Griko Nibras <[email protected]>", | ||
"repository": "https://github.com/graz-sh/graz.git", | ||
"homepage": "https://github.com/graz-sh/graz", | ||
|
@@ -49,6 +49,7 @@ | |
"@cosmjs/stargate": "<=0.31.3", | ||
"@cosmjs/tendermint-rpc": "<=0.31.3", | ||
"@leapwallet/cosmos-social-login-capsule-provider": "^0.0.41", | ||
"@tanstack/react-query": "5.62.0", | ||
"react": ">=17" | ||
}, | ||
"dependencies": { | ||
|
@@ -57,7 +58,6 @@ | |
"@dao-dao/cosmiframe": "0.1.0", | ||
"@keplr-wallet/cosmos": "0.12.156", | ||
"@metamask/providers": "12.0.0", | ||
"@tanstack/react-query": "5.62.0", | ||
"@terra-money/station-connector": "1.1.0", | ||
"@vectis/extension-client": "^0.7.2", | ||
"@walletconnect/sign-client": "2.17.2", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,43 @@ | ||
import type { QueryClientProviderProps } from "@tanstack/react-query"; | ||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
import { type FC, useEffect } from "react"; | ||
import { type FC, type ReactNode, useEffect } from "react"; | ||
|
||
import type { ConfigureGrazArgs } from "../actions/configure"; | ||
import { configureGraz } from "../actions/configure"; | ||
import { ClientOnly } from "./client-only"; | ||
import { GrazEvents } from "./events"; | ||
|
||
const queryClient = new QueryClient({ | ||
// | ||
}); | ||
|
||
export type GrazProviderProps = Partial<QueryClientProviderProps> & { | ||
export interface GrazProviderProps { | ||
grazOptions: ConfigureGrazArgs; | ||
}; | ||
children: ReactNode; | ||
} | ||
|
||
/** | ||
* Provider component which extends `@tanstack/react-query`'s {@link QueryClientProvider} with built-in query client | ||
* and various `graz` side effects | ||
* | ||
* Provider component configures various `graz` side effects. | ||
* Graz uses `@tanstack/react-query`'s features under the hood, hence you need to wrap `GrazProvider` with `QueryClientProvider`. | ||
* @example | ||
* ```tsx | ||
* // example next.js application in _app.tsx | ||
* export default function CustomApp({ Component, pageProps }: AppProps) { | ||
* return ( | ||
* <GrazProvider> | ||
* <Component {...pageProps} /> | ||
* </GrazProvider> | ||
* <QueryClientProvider queryClient={queryClient}> | ||
* <GrazProvider grazOptions={grazOptions}> | ||
* <Component {...pageProps} /> | ||
* </GrazProvider> | ||
* </QueryClientProvider> | ||
* ); | ||
* } | ||
* ``` | ||
* | ||
* @see https://tanstack.com/query | ||
*/ | ||
export const GrazProvider: FC<GrazProviderProps> = ({ children, grazOptions, ...props }) => { | ||
export const GrazProvider: FC<GrazProviderProps> = ({ children, grazOptions }) => { | ||
useEffect(() => { | ||
configureGraz(grazOptions); | ||
}, [grazOptions]); | ||
|
||
return ( | ||
<QueryClientProvider key="graz-provider" client={queryClient} {...props}> | ||
<ClientOnly> | ||
{children} | ||
<GrazEvents /> | ||
</ClientOnly> | ||
</QueryClientProvider> | ||
<ClientOnly> | ||
{children} | ||
<GrazEvents /> | ||
</ClientOnly> | ||
); | ||
}; |