Skip to content

Plaid link iframe is not removed #325

@lorentzimys

Description

@lorentzimys

Hi there!
I've noticed that iframe that is created by usePlaidLink hook is not removed on successful scenario, so when I start plaid linking process multiple times - a new iframe is created each time. The only case when iframe is not recreated is when I close plaid link window and onError callback is triggered.

I've noticed that this behaviour happens because usePlaidLink effect fires an exit method on unmout, but destroy callback is not triggered:
image

React component to reproduce:

import React, { useEffect } from 'react';
import { PlaidLinkOptions, usePlaidLink } from 'react-plaid-link';

interface PlaidLinkProps {
  options: PlaidLinkOptions;
}

export const PlaidLink: React.FC<PlaidLinkProps> = ({ options }) => {
  const { open, ready } = usePlaidLink(options);

  useEffect(() => {
    if (ready) {
      open();
    }
  }, [ready]);

  useEffect(() => {
    return () => {
      console.log('unmount');
    };
  }, []);

  return (<></>);
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions