Change to immutable SWR

This commit is contained in:
Willian Mitsuda 2021-12-18 07:09:10 -03:00
parent 7df1babd27
commit 61383a36d9
2 changed files with 4 additions and 4 deletions

View File

@ -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
); );

View File

@ -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;
} }