UNPKG

@dynamic-labs/sdk-react-core

Version:

A React SDK for implementing wallet web3 authentication and authorization to your website.

23 lines (20 loc) 834 B
'use client' import { jsx } from 'react/jsx-runtime'; import { createContext, useContext, useState, useMemo } from 'react'; const WalletContext = createContext(undefined); const WalletContextProvider = ({ children, }) => { const [isLoadingEmbeddedWallet, setIsLoadingEmbeddedWallet] = useState(false); const value = useMemo(() => ({ isLoadingEmbeddedWallet, setIsLoadingEmbeddedWallet, }), [isLoadingEmbeddedWallet]); return (jsx(WalletContext.Provider, { value: value, children: children })); }; const useWalletContext = () => { const context = useContext(WalletContext); if (context === undefined) { throw new Error('usage of useWalletContext not wrapped in `WalletContextProvider`.'); } return context; }; export { WalletContext, WalletContextProvider, useWalletContext };