36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { useClerk } from '@clerk/clerk-expo'
|
|
import * as Linking from 'expo-linking'
|
|
import { StyleSheet, Text, TouchableOpacity } from 'react-native'
|
|
|
|
export const SignOutButton = () => {
|
|
// Use `useClerk()` to access the `signOut()` function
|
|
const { signOut } = useClerk()
|
|
const handleSignOut = async () => {
|
|
try {
|
|
await signOut()
|
|
// Redirect to your desired page
|
|
Linking.openURL(Linking.createURL('/'))
|
|
} catch (err) {
|
|
// See https://clerk.com/docs/custom-flows/error-handling
|
|
// for more info on error handling
|
|
console.error(JSON.stringify(err, null, 2))
|
|
}
|
|
}
|
|
return (
|
|
<TouchableOpacity onPress={handleSignOut} style={styles.button}>
|
|
<Text>Sign out</Text>
|
|
</TouchableOpacity>
|
|
)
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
button: {
|
|
width: '40%',
|
|
height: 35,
|
|
backgroundColor: 'rgba(192, 196, 199, 1)',
|
|
borderRadius: 5,
|
|
alignItems: 'center',
|
|
justifyContent: 'center'
|
|
}
|
|
})
|