From 6e315bcbd34c622c8e7da4faed6dc97356fa5d2b Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 13 Mar 2024 19:22:43 +0800 Subject: [PATCH] wrap it in useCallback to have stable ref --- src/components/AddPlaidBankAccount.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/AddPlaidBankAccount.js b/src/components/AddPlaidBankAccount.js index b6fc639546a8..b676722f3c6c 100644 --- a/src/components/AddPlaidBankAccount.js +++ b/src/components/AddPlaidBankAccount.js @@ -218,6 +218,10 @@ function AddPlaidBankAccount({ ); } + const onError = useCallback((error) => { + Log.hmmm('[PlaidLink] Error: ', error.message); + }, []); + const renderPlaidLink = () => { if (Boolean(token) && !bankName) { return ( @@ -227,9 +231,7 @@ function AddPlaidBankAccount({ Log.info('[PlaidLink] Success!'); BankAccounts.openPlaidBankAccountSelector(publicToken, metadata.institution.name, allowDebit, bankAccountID); }} - onError={(error) => { - Log.hmmm('[PlaidLink] Error: ', error.message); - }} + onError={onError} onEvent={(event, metadata) => { BankAccounts.setPlaidEvent(event); // Handle Plaid login errors (will potentially reset plaid token and item depending on the error)