diff --git a/.changeset/early-impalas-peel.md b/.changeset/early-impalas-peel.md new file mode 100644 index 000000000000..9df1a2b40cda --- /dev/null +++ b/.changeset/early-impalas-peel.md @@ -0,0 +1,5 @@ +--- +"ledger-live-desktop": patch +--- + +LLD - fix toast issue when no click callback given diff --git a/apps/ledger-live-desktop/src/renderer/components/ToastOverlay/Toast.jsx b/apps/ledger-live-desktop/src/renderer/components/ToastOverlay/Toast.jsx index b7a1d9fbf7ef..31119e68f139 100644 --- a/apps/ledger-live-desktop/src/renderer/components/ToastOverlay/Toast.jsx +++ b/apps/ledger-live-desktop/src/renderer/components/ToastOverlay/Toast.jsx @@ -1,6 +1,6 @@ // @flow -import React, { useEffect } from "react"; +import React, { useCallback, useEffect } from "react"; import styled from "styled-components"; import Text from "~/renderer/components/Text"; import FakeLink from "~/renderer/components/FakeLink"; @@ -80,7 +80,7 @@ export function Toast({ duration?: number, onDismiss: (id: string) => void, dismissable?: boolean, - callback: any, + callback?: () => void, type?: string, title: string, cta?: string, @@ -117,16 +117,19 @@ export function Toast({ } }, [duration, id, onDismiss]); - return transitions.map(({ key, item, props }) => ( - { + const onClick = useCallback( + event => { + if (typeof callback === "function") { callback(); - onDismiss(id); - event.stopPropagation(); - }} - > + } + onDismiss(id); + event.stopPropagation(); + }, + [callback, id, onDismiss], + ); + + return transitions.map(({ key, item, props }) => ( +