UNPKG

template_assets

Version:

![Compatibility](https://img.shields.io/badge/compatibility-0.6.25-blue) [![Build Status](https://github.com/dfinity/examples/workflows/motoko-superheroes-example/badge.svg)](https://github.com/dfinity/examples/actions?query=workflow%3Amotoko-superheroes

44 lines (37 loc) 1.07 kB
import React, { useEffect } from 'react'; import { View } from '@components'; import { ConnectButton, ConnectDialog, Connect2ICProvider, useConnect } from "@connect2ic/react" import { useCanister } from '@connect2ic/react'; export const SettingsScreen = () => { const [superheroes, { loading, error }] = useCanister('superheroes'); const { isConnected, principal, activeProvider } = useConnect({ onConnect: () => { // Signed in }, onDisconnect: () => { // Signed out } }) useEffect(() => { fetch(); }, []); const fetch = async() => { let a = await superheroes.readAccount(); console.log(a); } const handleConnect = () => { try { window.ic.plug.requestConnect(); }catch(e) { alert(e); } } return( <View> <button onClick={handleConnect}>Connect Handle</button> <br/> <ConnectButton /> <ConnectDialog/> </View> ) }