updating to use clerk auth with new routing to signin page by default
This commit is contained in:
35
app/components/SignOutButton.tsx
Normal file
35
app/components/SignOutButton.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
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: '5%',
|
||||
backgroundColor: 'rgba(192, 196, 199, 1)',
|
||||
borderRadius: 5,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center'
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user