From 6e315bcbd34c622c8e7da4faed6dc97356fa5d2b Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 13 Mar 2024 19:22:43 +0800 Subject: [PATCH 1/4] 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) From 3a4df46618389bb6220641a5a1f73c3ff52e016e Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 15 Mar 2024 01:23:55 +0800 Subject: [PATCH 2/4] add type --- src/components/AddPlaidBankAccount.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/AddPlaidBankAccount.tsx b/src/components/AddPlaidBankAccount.tsx index e1f686cea6a7..3c966ae464fd 100644 --- a/src/components/AddPlaidBankAccount.tsx +++ b/src/components/AddPlaidBankAccount.tsx @@ -195,7 +195,7 @@ function AddPlaidBankAccount({ ); } - const onError = useCallback((error) => { + const onError = useCallback((error: ErrorEvent | null) => { Log.hmmm('[PlaidLink] Error: ', error?.message); }, []); From 1da9eab30c35036b975c0caa8b35994c9ae39aa4 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 15 Mar 2024 01:31:21 +0800 Subject: [PATCH 3/4] fix lint --- src/components/AddPlaidBankAccount.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/AddPlaidBankAccount.tsx b/src/components/AddPlaidBankAccount.tsx index 3c966ae464fd..89e92613f116 100644 --- a/src/components/AddPlaidBankAccount.tsx +++ b/src/components/AddPlaidBankAccount.tsx @@ -187,6 +187,10 @@ function AddPlaidBankAccount({ onInputChange(plaidAccountID); }; + const onError = useCallback((error: ErrorEvent | null) => { + Log.hmmm('[PlaidLink] Error: ', error?.message); + }, []); + if (isPlaidDisabled) { return ( @@ -195,10 +199,6 @@ function AddPlaidBankAccount({ ); } - const onError = useCallback((error: ErrorEvent | null) => { - Log.hmmm('[PlaidLink] Error: ', error?.message); - }, []); - const renderPlaidLink = () => { if (!!token && !bankName) { return ( From 0041cf03775c55cc97638c08a8626f3900df18ae Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 15 Mar 2024 17:03:03 +0800 Subject: [PATCH 4/4] renaming --- src/components/AddPlaidBankAccount.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/AddPlaidBankAccount.tsx b/src/components/AddPlaidBankAccount.tsx index 89e92613f116..4111d9cc8e6f 100644 --- a/src/components/AddPlaidBankAccount.tsx +++ b/src/components/AddPlaidBankAccount.tsx @@ -187,7 +187,7 @@ function AddPlaidBankAccount({ onInputChange(plaidAccountID); }; - const onError = useCallback((error: ErrorEvent | null) => { + const handlePlaidError = useCallback((error: ErrorEvent | null) => { Log.hmmm('[PlaidLink] Error: ', error?.message); }, []); @@ -208,7 +208,7 @@ function AddPlaidBankAccount({ Log.info('[PlaidLink] Success!'); BankAccounts.openPlaidBankAccountSelector(publicToken, metadata?.institution?.name ?? '', allowDebit, bankAccountID); }} - onError={onError} + onError={handlePlaidError} onEvent={(event, metadata) => { BankAccounts.setPlaidEvent(event); // Handle Plaid login errors (will potentially reset plaid token and item depending on the error)