diff --git a/articles/quickstart/native/react-native-expo/files/app.md b/articles/quickstart/native/react-native-expo/files/app.md index 6cd1a1372d..76f15e528c 100644 --- a/articles/quickstart/native/react-native-expo/files/app.md +++ b/articles/quickstart/native/react-native-expo/files/app.md @@ -9,7 +9,7 @@ import {Button, Text, View, StyleSheet} from 'react-native'; import {useAuth0, Auth0Provider} from 'react-native-auth0'; const Home = () => { - const {authorize, clearSession, user, error} = useAuth0(); + const {authorize, clearSession, user, error, isLoading} = useAuth0(); const onLogin = async () => { try { @@ -27,6 +27,10 @@ const Home = () => { } }; + if (isLoading) { + return Loading; + } + const loggedIn = user !== undefined && user !== null; return ( diff --git a/articles/quickstart/native/react-native-expo/interactive.md b/articles/quickstart/native/react-native-expo/interactive.md index 76cd50dd81..5db1aedacd 100644 --- a/articles/quickstart/native/react-native-expo/interactive.md +++ b/articles/quickstart/native/react-native-expo/interactive.md @@ -176,7 +176,7 @@ Still having issues? Check out our [documentation](https://auth0.com/docs) or vi ::: :::: -## Show user profile information {{{ data-action=code data-code="App.js#28:29" }}} +## Show user profile information {{{ data-action=code data-code="App.js#32:34" }}} The `useAuth0` hook exposes a `user` object that contains information about the authenticated user. You can use this to access user profile information about the authenticated user that has been decoded from the [ID token](https://auth0.com/docs/secure/tokens/id-tokens). diff --git a/articles/quickstart/native/react-native/files/app.md b/articles/quickstart/native/react-native/files/app.md index 0acb8d45d0..9f233d2155 100644 --- a/articles/quickstart/native/react-native/files/app.md +++ b/articles/quickstart/native/react-native/files/app.md @@ -11,7 +11,7 @@ import {Button, Text, View, StyleSheet} from 'react-native'; import {useAuth0, Auth0Provider} from 'react-native-auth0'; const Home = () => { - const {authorize, clearSession, user} = useAuth0(); + const {authorize, clearSession, user, error, isLoading} = useAuth0(); const onLogin = async () => { try { @@ -29,12 +29,17 @@ const Home = () => { } }; + if (isLoading) { + return Loading; + } + const loggedIn = user !== undefined && user !== null; return ( {loggedIn && You are logged in as {user.name}} {!loggedIn && You are not logged in} + {error && {error.message}}