Skip to content

Commit

Permalink
Merge pull request Expensify#15752 from mdneyazahmad/fix/15309-page-f…
Browse files Browse the repository at this point in the history
…lash

fix: prevent screen flashes on payments page (bank account)
  • Loading branch information
johnmlee101 authored Mar 9, 2023
2 parents 3c57501 + 01243c2 commit b08bf48
Showing 1 changed file with 8 additions and 2 deletions.
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

0 comments on commit b08bf48

Please sign in to comment.