-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTokenClearingView.js
More file actions
26 lines (26 loc) · 810 Bytes
/
Copy pathTokenClearingView.js
File metadata and controls
26 lines (26 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// @flow
import React, {useState, useCallback} from 'react';
import {Button, TextInput} from 'react-native';
import type {User} from '@react-native-community/google-signin';
import {GoogleSignin} from '@react-native-community/google-signin';
export function TokenClearingView({userInfo}: {userInfo: User}) {
const [tokenToClear, setToken] = useState(userInfo.idToken);
const clearToken = useCallback(async () => {
try {
await GoogleSignin.clearCachedToken(tokenToClear);
console.warn('success!');
} catch (err) {
console.error(err);
}
}, [tokenToClear]);
return (
<>
<TextInput
onChangeText={setToken}
value={tokenToClear}
style={{height: 50, width: 200}}
/>
<Button title="clear token" onPress={clearToken} />
</>
);
}