Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/components/PlaidLink/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {useCallback, useEffect} from 'react';
import {useCallback, useEffect, useState} from 'react';
import {usePlaidLink} from 'react-plaid-link';
import {plaidLinkPropTypes, plaidLinkDefaultProps} from './plaidLinkPropTypes';
import Log from '../../libs/Log';

const PlaidLink = (props) => {
const [isPlaidLoaded, setIsPlaidLoaded] = useState(false);
const onSuccess = useCallback((publicToken, metadata) => {
props.onSuccess({publicToken, metadata});
}, []);
Expand All @@ -18,6 +19,7 @@ const PlaidLink = (props) => {
onEvent: (event, metadata) => {
Log.info('[PlaidLink] Event: ', false, {event, metadata});
},
onLoad: () => setIsPlaidLoaded(true),

// The redirect URI with an OAuth state ID. Needed to re-initialize the PlaidLink after directing the
// user to their respective bank platform
Expand All @@ -34,8 +36,12 @@ const PlaidLink = (props) => {
return;
}

if (!isPlaidLoaded) {
return;
}

open();
}, [ready, error]);
}, [ready, error, isPlaidLoaded]);

return null;
};
Expand Down