Signing out
To sign a user out, we use the signOut function returned from withDoormanUser or useDoormanUser.
For a full walkthrough of these functions, see accessing the current user.

Example

React Hooks
Higher Order Component
Class Components
1
import React from 'react'
2
import { Text } from 'react-native'
3
import { useDoormanUser } from 'react-native-doorman'
4
5
const UserDetails = () => {
6
const { signOut } = useDoormanUser()
7
8
return <Text onPress={signOut}>Sign Out!</Text>
9
}
10
11
export default UserDetails
Copied!
1
import React from 'react'
2
import { Text } from 'react-native'
3
import { withDoormanUser } from 'react-native-doorman'
4
5
function UserDetails(props) {
6
// receives a user prop
7
const { signOut } = props.user
8
9
return <Text onPress={signOut}>Sign Out!</Text>
10
}
11
12
export default withDoormanUser(UserDetails)
Copied!
1
import React from 'react'
2
import { Text } from 'react-native'
3
import { withDoormanUser } from 'react-native-doorman'
4
5
class UserDetails extends React.Component {
6
render() {
7
// access via this.props.user
8
const { signOut } = this.props.user
9
10
return <Text onPress={signOut}>Sign Out!</Text>
11
}
12
}
13
14
export default withDoormanUser(UserDetails)
Copied!
withDoormanUser and useDoormanUser should only be used on screens that show up after a user has signed in. If you use either one in a component when the user hasn't authenticated yet, it will throw an error.

Copy link
Contents
Example