Skip to content

Commit 66531cc

Browse files
authored
fix: refresh data and clients on network switch (#76)
1 parent bc1e27d commit 66531cc

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/features/common/components/platform-provider-inner.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { NetworkConfig, useTheme } from '@/features/settings/data'
77
import { SupportedProviders } from '@txnlab/use-wallet'
88

99
type Props = PropsWithChildren<{
10+
key: string
1011
networkConfig: NetworkConfig
1112
walletProviders: SupportedProviders | null
1213
store?: JotaiStore // This is only used for unit tests

src/features/common/components/platform-provider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ export function PlatformProvider({ children }: PropsWithChildren) {
3333
})
3434

3535
return (
36-
<PlatformProviderInner networkConfig={networkConfig} walletProviders={walletProviders}>
36+
// The key passed to PlatformProviderInner is important as it controls the storeRef in useDataStore
37+
<PlatformProviderInner key={networkConfig.id} networkConfig={networkConfig} walletProviders={walletProviders}>
3738
{children}
3839
</PlatformProviderInner>
3940
)

src/tests/test-platform-provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function TestPlatformProvider({ children, store }: Props) {
2323
})
2424

2525
return (
26-
<PlatformProviderInner networkConfig={networkConfig} walletProviders={walletProviders} store={store}>
26+
<PlatformProviderInner key={networkConfig.id} networkConfig={networkConfig} walletProviders={walletProviders} store={store}>
2727
{children}
2828
</PlatformProviderInner>
2929
)

0 commit comments

Comments
 (0)