@davatar/react
Advanced tools
Comparing version 1.10.3 to 1.10.4
@@ -21,2 +21,2 @@ import { BaseProvider } from '@ethersproject/providers'; | ||
export declare function AvatarProvider({ provider, batchLookups, children }: AvatarProviderProps): JSX.Element; | ||
export declare function useAvatarEthersProvider(): BaseProvider; | ||
export declare function useAvatarEthersProvider(provider?: BaseProvider | null): BaseProvider; |
@@ -42,10 +42,16 @@ "use strict"; | ||
exports.AvatarProvider = AvatarProvider; | ||
function useAvatarEthersProvider() { | ||
function useAvatarEthersProvider(provider) { | ||
const avatarContext = (0, react_1.useContext)(AvatarContext); | ||
if (!avatarContext) { | ||
return (0, providers_1.getDefaultProvider)(); | ||
} | ||
return avatarContext.provider; | ||
const defaultProvider = (0, react_1.useMemo)(() => { | ||
if (!avatarContext) { | ||
if (provider) { | ||
return provider; | ||
} | ||
return (0, providers_1.getDefaultProvider)(); | ||
} | ||
return avatarContext.provider; | ||
}, [avatarContext, provider]); | ||
return defaultProvider; | ||
} | ||
exports.useAvatarEthersProvider = useAvatarEthersProvider; | ||
//# sourceMappingURL=AvatarProvider.js.map |
@@ -53,4 +53,4 @@ "use strict"; | ||
const [loaded, setLoaded] = (0, react_1.useState)(false); | ||
const avatarEthersProvider = (0, AvatarProvider_1.useAvatarEthersProvider)(); | ||
const ethersProvider = (0, react_1.useMemo)(() => provider || avatarEthersProvider, [provider, avatarEthersProvider]); | ||
const avatarEthersProvider = (0, AvatarProvider_1.useAvatarEthersProvider)(provider); | ||
const ethersProvider = avatarEthersProvider; | ||
(0, react_1.useEffect)(() => { | ||
@@ -57,0 +57,0 @@ if (!uri && address) { |
{ | ||
"name": "@davatar/react", | ||
"version": "1.10.3", | ||
"version": "1.10.4", | ||
"description": "An ENS avatar implementation for React", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/metaphor-xyz/davatar-helpers", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
579717
8470