Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plaid Link returns noop for open function #268

Open
Namanp opened this issue Jul 14, 2022 · 0 comments
Open

Plaid Link returns noop for open function #268

Namanp opened this issue Jul 14, 2022 · 0 comments

Comments

@Namanp
Copy link

Namanp commented Jul 14, 2022

I've encountered a bug with the usePlaidLink hook where the open method returned is a noop. Digging into the source code, I believe the issue is here: https://github.com/plaid/react-plaid-link/blob/master/src/usePlaidLink.ts#L51 (window.Plaid is undefined). It seems to happen more often when there are multiple components using the usePlaidLink hook (multiple microdeposits that user need to enter deposits for).

I think this is the case because Error loading Plaid: null appears in the console so there is no error but it still goes down that branch.

My hacky solution right now that works:
I use a custom hook to re-render the component on some interval if window.Plaid is undefined. I then make the useEffect hook inside of usePlaidLink retrigger by passing in a different value for products parameter. Here's a snippet:

function PlaidButton({ plaidToken }) {
  const onSuccess = async () => {}; 
  const onExit = async () => {}; // took out actual logic in onSuccess and onExit

  useRetryUntilResolved(() => typeof window.Plaid !== 'undefined'); // custom hook to retry

  const { open } = usePlaidLink({
    token: plaidToken,
    onSuccess,
    onExit,
    product: window.Plaid ? ['auth', 'transactions'] : ['auth'],
  });

  return <Button title='Verify Microdeposit Amounts' onClick={open as EventFunctionT} />;
} 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant