Skip to content

fix: recreate instance immediately#350

Open
KATT wants to merge 3 commits into
plaid:masterfrom
KATT:fix-invalidate
Open

fix: recreate instance immediately#350
KATT wants to merge 3 commits into
plaid:masterfrom
KATT:fix-invalidate

Conversation

@KATT
Copy link
Copy Markdown
Contributor

@KATT KATT commented Aug 26, 2024

What

  • Recreates the Plaid instance immediately in a useMemo() rather than a useEffect()
  • Trashes the old Plaid instance when unmounting

Why

I have code that takes care of invalidating expired tokens and recreates the Plaid instance when/if needed & since the Plaid token isn't resolved immediately I can't trust the connect.open() to be immediately pointing to the new token rather than the old one

Comment thread src/usePlaidLink.ts
}
}, [plaid])

const ready = !!plaid && !loading && iframeLoaded;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was previously

const ready = plaid != null && (!loading || iframeLoaded);

But reading that code, it seems to me that iframeLoaded is completely unused - it can't be true without being first loading === true, so I'm guessing this fixes some edge-case bug

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

Successfully merging this pull request may close these issues.

1 participant