diff --git a/packages/core/src/provider.tsx b/packages/core/src/provider.tsx index 73ccb19..24f248b 100644 --- a/packages/core/src/provider.tsx +++ b/packages/core/src/provider.tsx @@ -22,6 +22,7 @@ export type Web3ContextType = { provider: T | undefined ENSNames: ReturnType ENSName: ReturnType + hooks: ReturnType } const Web3Context = createContext(undefined) @@ -50,6 +51,7 @@ export function Web3ReactProvider({ network, lookupENS = true, }: Web3ReactProviderProps) { + const hooks = getPriorityConnector(...connectors) const { usePriorityConnector, useSelectedChainId, @@ -61,7 +63,7 @@ export function Web3ReactProvider({ useSelectedProvider, useSelectedENSNames, useSelectedENSName, - } = getPriorityConnector(...connectors) + } = hooks const priorityConnector = usePriorityConnector() const connector = connectorOverride ?? priorityConnector @@ -94,6 +96,7 @@ export function Web3ReactProvider({ provider, ENSNames, ENSName, + hooks, }} > {children} @@ -101,8 +104,8 @@ export function Web3ReactProvider({ ) } -export function useWeb3React() { - const web3 = useContext(Web3Context as Context | undefined>) - if (!web3) throw Error('useWeb3React can only be used within the Web3ReactProvider component') - return web3 +export function useWeb3React(): Web3ContextType { + const context = useContext(Web3Context as Context | undefined>) + if (!context) throw Error('useWeb3React can only be used within the Web3ReactProvider component') + return context }