Change to immutable SWR
This commit is contained in:
parent
7df1babd27
commit
61383a36d9
@ -5,7 +5,7 @@ import {
|
|||||||
TransactionDescription,
|
TransactionDescription,
|
||||||
} from "@ethersproject/abi";
|
} from "@ethersproject/abi";
|
||||||
import { BigNumberish } from "@ethersproject/bignumber";
|
import { BigNumberish } from "@ethersproject/bignumber";
|
||||||
import useSWR from "swr";
|
import useSWRImmutable from "swr/immutable";
|
||||||
import { RuntimeContext } from "./useRuntime";
|
import { RuntimeContext } from "./useRuntime";
|
||||||
import { fourBytesURL } from "./url";
|
import { fourBytesURL } from "./url";
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ export const use4Bytes = (
|
|||||||
return fetch4Bytes(assetsURLPrefix, key.slice(2));
|
return fetch4Bytes(assetsURLPrefix, key.slice(2));
|
||||||
};
|
};
|
||||||
|
|
||||||
const { data, error } = useSWR<FourBytesEntry | null | undefined>(
|
const { data, error } = useSWRImmutable<FourBytesEntry | null | undefined>(
|
||||||
rawFourBytes,
|
rawFourBytes,
|
||||||
fourBytesFetcher
|
fourBytesFetcher
|
||||||
);
|
);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useState, useEffect, useContext } from "react";
|
import { useState, useEffect, useContext } from "react";
|
||||||
import { BaseProvider } from "@ethersproject/providers";
|
import { BaseProvider } from "@ethersproject/providers";
|
||||||
import { getAddress, isAddress } from "@ethersproject/address";
|
import { getAddress, isAddress } from "@ethersproject/address";
|
||||||
import useSWR from "swr";
|
import useSWRImmutable from "swr/immutable";
|
||||||
import { mainResolver } from "./api/address-resolver";
|
import { mainResolver } from "./api/address-resolver";
|
||||||
import { SelectedResolvedName } from "./api/address-resolver/CompositeAddressResolver";
|
import { SelectedResolvedName } from "./api/address-resolver/CompositeAddressResolver";
|
||||||
import { RuntimeContext } from "./useRuntime";
|
import { RuntimeContext } from "./useRuntime";
|
||||||
@ -79,7 +79,7 @@ export const useResolvedAddress = (
|
|||||||
return mainResolver.resolveAddress(provider, address);
|
return mainResolver.resolveAddress(provider, address);
|
||||||
};
|
};
|
||||||
|
|
||||||
const { data, error } = useSWR(address, fetcher);
|
const { data, error } = useSWRImmutable(address, fetcher);
|
||||||
if (error) {
|
if (error) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user