Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added isLoading to quickstart #10287

Merged
merged 2 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading