Skip to content

Commit f920644

Browse files
authored
Fix reload() (#148)
Adapt to the useSWR() deprecation of revalidate(). See vercel/swr#1332
1 parent 673847e commit f920644

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/core.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ function normalizeFetcher(fetcher: FetcherProp): Fetcher<unknown> {
5555

5656
// ethereum
5757
if (isFetcherDeclarationEthereum(fetcher)) {
58-
return ethereumFetcher(fetcher[1]) as Fetcher<EthereumFetcherConfigDeclaration>
58+
return ethereumFetcher(fetcher[1]) as Fetcher<
59+
EthereumFetcherConfigDeclaration
60+
>
5961
}
6062

6163
// custom fetcher (or wrong value)
@@ -138,9 +140,12 @@ function useNft(contractAddress: Address, tokenId: string): NftResult {
138140
)
139141

140142
return useMemo(() => {
141-
const { error, data, revalidate } = result
143+
const { error, data, mutate } = result
142144

143-
const reload = () => revalidate()
145+
const reload = () =>
146+
mutate()
147+
.then(() => true)
148+
.catch(() => false)
144149

145150
if (error === undefined && data === undefined) {
146151
return {

0 commit comments

Comments
 (0)