From f2aa2ae98da037b51c26d3c60a97f8d052fdd0a4 Mon Sep 17 00:00:00 2001 From: Matej Lubej Date: Fri, 19 Apr 2024 07:32:56 +0200 Subject: [PATCH] Fix ContextProviders default value --- src/hooks/useEIP1193.ts | 2 +- src/hooks/useEIP6963.ts | 2 +- src/hooks/useEIP6963Manager.ts | 2 +- src/hooks/useWeb3.ts | 2 +- src/hooks/useWrapForm.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hooks/useEIP1193.ts b/src/hooks/useEIP1193.ts index ce0d2d5..edbf41a 100644 --- a/src/hooks/useEIP1193.ts +++ b/src/hooks/useEIP1193.ts @@ -3,7 +3,7 @@ import { EIP1193Context } from '../providers/EIP1193Context' export const useEIP1193 = () => { const value = useContext(EIP1193Context) - if (value === undefined) { + if (Object.keys(value).length === 0) { throw new Error('[useEIP1193] Component not wrapped within a Provider') } diff --git a/src/hooks/useEIP6963.ts b/src/hooks/useEIP6963.ts index 5568a40..cc915eb 100644 --- a/src/hooks/useEIP6963.ts +++ b/src/hooks/useEIP6963.ts @@ -3,7 +3,7 @@ import { EIP6963Context } from '../providers/EIP6963Context.ts' export const useEIP6963 = () => { const value = useContext(EIP6963Context) - if (value === undefined) { + if (Object.keys(value).length === 0) { throw new Error('[useEIP6963] Component not wrapped within a Provider') } diff --git a/src/hooks/useEIP6963Manager.ts b/src/hooks/useEIP6963Manager.ts index acd0393..d3b3cbf 100644 --- a/src/hooks/useEIP6963Manager.ts +++ b/src/hooks/useEIP6963Manager.ts @@ -3,7 +3,7 @@ import { EIP6963ManagerContext } from '../providers/EIP6963ManagerContext.ts' export const useEIP6963Manager = () => { const value = useContext(EIP6963ManagerContext) - if (value === undefined) { + if (Object.keys(value).length === 0) { throw new Error('[useEIP6963Manager] Component not wrapped within a Provider') } diff --git a/src/hooks/useWeb3.ts b/src/hooks/useWeb3.ts index 1030fad..1ed9986 100644 --- a/src/hooks/useWeb3.ts +++ b/src/hooks/useWeb3.ts @@ -3,7 +3,7 @@ import { Web3Context } from '../providers/Web3Context' export const useWeb3 = () => { const value = useContext(Web3Context) - if (value === undefined) { + if (Object.keys(value).length === 0) { throw new Error('[useWeb3] Component not wrapped within a Provider') } diff --git a/src/hooks/useWrapForm.ts b/src/hooks/useWrapForm.ts index 990cd82..21733a9 100644 --- a/src/hooks/useWrapForm.ts +++ b/src/hooks/useWrapForm.ts @@ -3,7 +3,7 @@ import { WrapFormContext } from '../providers/WrapFormContext' export const useWrapForm = () => { const value = useContext(WrapFormContext) - if (value === undefined) { + if (Object.keys(value).length === 0) { throw new Error('[useWrapForm] Component not wrapped within a Provider') }