File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { CartesiProvider } from "@cartesi/wagmi" ;
22import { QueryClient , QueryClientProvider } from "@tanstack/react-query" ;
3- import type { FC , PropsWithChildren } from "react" ;
3+ import { useMemo , type FC , type PropsWithChildren } from "react" ;
44import { useSelectedNodeConnection } from "../components/connection/hooks" ;
55import queryClient from "./queryClient" ;
66import WalletProvider from "./WalletProvider" ;
77
8- const newQueryClient = new QueryClient ( ) ;
9-
108const DataProvider : FC < PropsWithChildren > = ( { children } ) => {
119 const selectedConnection = useSelectedNodeConnection ( ) ;
12-
13- const client =
14- selectedConnection ?. type === "system_mock"
15- ? queryClient
16- : newQueryClient ;
10+ const client = useMemo (
11+ ( ) =>
12+ selectedConnection ?. type === "system_mock"
13+ ? queryClient
14+ : new QueryClient ( ) ,
15+ [ selectedConnection ?. type ] ,
16+ ) ;
1717
1818 return (
19- < QueryClientProvider client = { client } >
19+ < QueryClientProvider client = { client } key = { selectedConnection ?. id } >
2020 < CartesiProvider rpcUrl = { selectedConnection ?. url ?? "" } >
2121 < WalletProvider > { children } </ WalletProvider >
2222 </ CartesiProvider >
You can’t perform that action at this time.
0 commit comments