import { useContext } from 'react' import { ConnectionContext } from '../providers/ConnectionProvider' import type { Network } from '@meshconnect/uwc-types' /** * Hook for accessing the list of configured networks * @returns Array of network configurations * @throws Error if used outside of ConnectionProvider * @example * ```tsx * const networks = useNetworks() * * networks.forEach(network => { * console.log(`${network.name}: ${network.id}`) * }) * ``` */ export function useNetworks(): Network[] { const context = useContext(ConnectionContext) if (!context) { throw new Error('useNetworks must be used within a ConnectionProvider') } return context.networks }