Skip to content

Commit 48dd8c8

Browse files
committed
fix setState loop for keepStaleData flag
1 parent b3a2a08 commit 48dd8c8

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

examples/app.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { CachePolicy, Entry, useAssetsInfo } from "../src";
44
import { client } from "../src";
55
import { DataStatus } from "../src/cache/DataStatus";
66
import { useAssetsFullInfo } from "../src/react";
7-
// import { createNamespaceFactory } from "../src/createSocketNamespace";
87
import { useSubscription } from "../src/react/useSubscription";
98
import { ResponsePayload } from "../src/requests/ResponsePayload";
109
import { endpoint, API_TOKEN } from "./config";
@@ -14,9 +13,6 @@ import { VStack } from "./VStack";
1413

1514
client.configure({ url: endpoint, apiToken: API_TOKEN });
1615

17-
// const endpoint = "wss://api-staging.zerion.io";
18-
// const namespace = createNamespaceFactory(endpoint);
19-
2016
const ETH = "eth";
2117
const USDC = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48";
2218
const UNI = "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984";
@@ -193,7 +189,7 @@ function App() {
193189
))}
194190
</div>
195191
<Helpers currency={currency} />
196-
<EnabledTest />
192+
<EnabledTest currency={currency} />
197193
</VStack>
198194
);
199195
}

src/react/useSubscription.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ export function useSubscription<
103103
[client, hookOptions]
104104
);
105105
if (newEntry !== entry) {
106-
guardedSetEntry(newEntry);
106+
if (!keepStaleData) {
107+
guardedSetEntry(newEntry);
108+
}
107109
}
108110

109111
useEffect(() => {

0 commit comments

Comments
 (0)