useDisconnectWallet
The useConnectWallet
hook is a mutation hook for disconnecting from an active wallet connection,
if currently connected.
Live Editor
function withProviders( Component: React.FunctionComponent<object>, walletProviderProps?: Omit<ComponentProps<typeof WalletProvider>, 'children'>, ) { // Work around server-side pre-rendering const queryClient = new QueryClient(); const networks = { testnet: { url: getFullnodeUrl('testnet') }, }; return () => { const [shouldRender, setShouldRender] = useState(false); useEffect(() => { setShouldRender(true); }, [setShouldRender]); if (!shouldRender) { return null; } return ( <QueryClientProvider client={queryClient}> <IotaClientProvider networks={networks}> <WalletProvider {...walletProviderProps}> <Component /> </WalletProvider> </IotaClientProvider> </QueryClientProvider> ); }; } const UseDisconnectWalletExample = withProviders(() => { const { mutate: disconnect } = useDisconnectWallet(); return ( <div style={{ padding: 20 }}> <ConnectButton /> <div> <button onClick={() => disconnect()}>Disconnect</button> </div> </div> ); }); render(<UseDisconnectWalletExample/>)
Result
Loading...
Arguments
There are no arguments for useConnectWallet
.
Feedback Form