useDeleteAccount
Format: options => [state, delete]
This hook returns a set of utilities for building a delete account control.
Returned values
const [{
deleting, // true when executing the request
error, // error string in the request
},
deleteFunction // executes the delete request
] = useDeleteAccount()
Recommended configuration
Same as useSignIn
. You can also set your storage
method and storageKey
, because Croods-auth will use those values to clear the headers from your localStorage
after the delete request succeeds.
import { AsyncStorage } from 'react-native'
const tuple = useSignOut({
storage: AsyncStorage,
storageKey: 'mySp3ci4lK3y',
})
You also probably want to redirect the user by setting a afterSuccess
to this hook.
Usage samples
const [{ currentUser }] = useCurrentUser()
const [{ deleting }, deleteAccount] = useDeleteAccount()
const text = deleting ? 'Deleting account...' : 'Delete account'
return (
<button onClick={() => {
const message = `Are you sure you want to delete ${currentUser.name}?`
const userAgreed = confirm(message)
userAgreed && deleteAccount()
}}>
{text}
</button>
)