From d60389012f6f562a4574349a284cbcd39da66410 Mon Sep 17 00:00:00 2001 From: Jim Arment <104024671+jima-stripe@users.noreply.github.com> Date: Fri, 16 Jun 2023 14:59:23 -0700 Subject: [PATCH] Update src/components/createElementComponent.tsx Co-authored-by: fruchtose-stripe <122935036+fruchtose-stripe@users.noreply.github.com> --- src/components/createElementComponent.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/createElementComponent.tsx b/src/components/createElementComponent.tsx index 7c71aa3..12035c5 100644 --- a/src/components/createElementComponent.tsx +++ b/src/components/createElementComponent.tsx @@ -173,16 +173,16 @@ const createElementComponent = ( React.useLayoutEffect(() => { return () => { - try { - if ( - elementRef.current && - typeof elementRef.current.destroy === 'function' - ) { + if ( + elementRef.current && + typeof elementRef.current.destroy === 'function' + ) { + try { elementRef.current.destroy(); elementRef.current = null; + } catch (error) { + // Do nothing } - } catch (error) { - // Do nothing } }; }, []);