import { View, Text } from "react-native";
import { useRownd } from "@rownd/react";
export default function MyProtectedComponent(props) {
const { is_authenticated, user, requestSignIn, getAccessToken } = useRownd();
// You can also request a sign in without a user pressing a button
// by calling requestSignIn() from a useEffect callback.
// useEffect(() => {
// if (!is_authenticated) {
// requestSignIn();
// }
// }, [is_authenticated]);
return (
<View>
{is_authenticated ? (
<>
<h1>Welcome {user.data.first_name}</h1>
<button onClick={() => getAccessToken()}>Get access token</button>
</>
) : (
<>
<Text>Please sign in to continue</Text>
<Pressable onPress={() => requestSignIn()}>
<Text>Sign in</Text>
</Pressable>
</>
)}
</View>
);
}