forked from plaid/react-plaid-link
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhooks.js
53 lines (45 loc) · 1.12 KB
/
hooks.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React, { useCallback } from 'react';
import { usePlaidLink } from '../src';
const App = props => {
const onSuccess = useCallback(
(token, metadata) => console.log('onSuccess', token, metadata),
[]
);
const onEvent = useCallback(
(eventName, metadata) => console.log('onEvent', eventName, metadata),
[]
);
const onExit = useCallback(
(err, metadata) => console.log('onExit', err, metadata),
[]
);
const config = {
clientName: props.clientName || '',
env: props.env || 'sandbox',
product: props.product || ['auth'],
publicKey: props.publicKey,
token: props.token,
onSuccess,
onEvent,
onExit,
// –– optional parameters
// webhook: props.webhook || null,
// countryCodes: props.countryCodes || ['US'],
// language: props.language || 'en',
// ...
};
const { open, ready, error } = usePlaidLink(config);
return (
<>
<button
type="button"
className="button"
onClick={() => open()}
disabled={!ready || error}
>
Open Plaid Link
</button>
</>
);
};
export default App;