Skip to content

Commit

Permalink
Added isLoading to quickstart (#10287)
Browse files Browse the repository at this point in the history
  • Loading branch information
poovamraj authored Aug 11, 2023
1 parent 54f9b52 commit a27905a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
6 changes: 5 additions & 1 deletion articles/quickstart/native/react-native-expo/files/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -27,6 +27,10 @@ const Home = () => {
}
};

if (isLoading) {
return <View style={styles.container}><Text>Loading</Text></View>;
}

const loggedIn = user !== undefined && user !== null;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
7 changes: 6 additions & 1 deletion articles/quickstart/native/react-native/files/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -29,12 +29,17 @@ const Home = () => {
}
};

if (isLoading) {
return <View style={styles.container}><Text>Loading</Text></View>;
}

const loggedIn = user !== undefined && user !== null;

return (
<View style={styles.container}>
{loggedIn && <Text>You are logged in as {user.name}</Text>}
{!loggedIn && <Text>You are not logged in</Text>}
{error && <Text>{error.message}</Text>}

<Button
onPress={loggedIn ? onLogout : onLogin}
Expand Down
2 changes: 1 addition & 1 deletion articles/quickstart/native/react-native/interactive.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,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 decoded user profile information about the authenticated user from the [ID token](https://auth0.com/docs/secure/tokens/id-tokens).

Expand Down

0 comments on commit a27905a

Please sign in to comment.