From b2fa005f562b19713af0de282dd3e2aadb481128 Mon Sep 17 00:00:00 2001 From: Pavlo Mykhailenko Date: Fri, 28 Jan 2022 16:13:54 +0200 Subject: [PATCH] set valid open state after success connection --- src/factory.ts | 4 ++++ src/usePlaidLink.ts | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/factory.ts b/src/factory.ts index e750dfdf..70bc78f6 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -50,6 +50,10 @@ export const createPlaid = (options: PlaidLinkOptions) => { config.onExit && config.onExit(error, metadata); state.onExitCallback && state.onExitCallback(); }, + onSuccess: (public_token, metadata) => { + state.open = false; + options.onSuccess && options.onSuccess(public_token, metadata) + }, }); const open = () => { diff --git a/src/usePlaidLink.ts b/src/usePlaidLink.ts index 53535db3..aa412a2a 100644 --- a/src/usePlaidLink.ts +++ b/src/usePlaidLink.ts @@ -52,6 +52,9 @@ export const usePlaidLink = (options: PlaidLinkOptions) => { setIframeLoaded(true); options.onLoad && options.onLoad(); }, + onSuccess: (public_token, metadata) => { + options.onSuccess && options.onSuccess(public_token, metadata) + }, }); setPlaid(next);