11import { StatusBar } from "expo-status-bar" ;
22import { useState } from "react" ;
33import { StyleSheet , Text , View , Button } from "react-native" ;
4- import Web3Auth , { LOGIN_PROVIDER , OPENLOGIN_NETWORK } from "@web3auth/react-native-sdk" ;
4+ import Web3Auth , { LOGIN_PROVIDER , OPENLOGIN_NETWORK , State } from "@web3auth/react-native-sdk" ;
55import Constants , { AppOwnership } from "expo-constants" ;
66import * as Linking from "expo-linking" ;
77import * as WebBrowser from "expo-web-browser" ;
@@ -19,6 +19,7 @@ const resolvedRedirectUrl =
1919export default function App ( ) {
2020 const [ key , setKey ] = useState ( "" ) ;
2121 const [ errorMsg , setErrorMsg ] = useState ( "" ) ;
22+ const [ userInfo , setUserInfo ] = useState < State > ( null ) ;
2223 const login = async ( ) => {
2324 try {
2425 const web3auth = new Web3Auth ( WebBrowser , {
@@ -30,18 +31,18 @@ export default function App() {
3031 redirectUrl : resolvedRedirectUrl ,
3132 } ) ;
3233 setKey ( state . privKey || "no key" ) ;
34+ setUserInfo ( state ) ;
3335 } catch ( e ) {
3436 console . error ( e ) ;
3537 setErrorMsg ( String ( e ) ) ;
3638 }
3739 } ;
3840 return (
3941 < View style = { styles . container } >
40- < Text > Key: { key } </ Text >
41- < Text > Error: { errorMsg } </ Text >
42+ { key !== "" ? < Text > Key: { key } </ Text > : null }
43+ { userInfo !== null ? < Text > UserInfo: { JSON . stringify ( userInfo ) } </ Text > : null }
44+ { errorMsg !== "" ? < Text > Error: { errorMsg } </ Text > : null }
4245 < Text > Linking URL: { resolvedRedirectUrl } </ Text >
43- < Text > appOwnership: { Constants . appOwnership } </ Text >
44- < Text > executionEnvironment: { Constants . executionEnvironment } </ Text >
4546 < Button title = "Login with Web3Auth" onPress = { login } />
4647 < StatusBar style = "auto" />
4748 </ View >
0 commit comments