From 5bb68393ddd02602223224eb84717dc1c5211485 Mon Sep 17 00:00:00 2001 From: Jean-Marc Millet Date: Thu, 6 Jun 2024 11:39:43 +0200 Subject: [PATCH 1/2] call useHistory in EmptyState and remove history from props --- .../emptystate/Emptystate.component.tsx | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/lib/components/emptystate/Emptystate.component.tsx b/src/lib/components/emptystate/Emptystate.component.tsx index aad25aaff8..8cc20be3a9 100644 --- a/src/lib/components/emptystate/Emptystate.component.tsx +++ b/src/lib/components/emptystate/Emptystate.component.tsx @@ -5,6 +5,7 @@ import { Button } from '../buttonv2/Buttonv2.component'; import { Icon, IconName } from '../icon/Icon.component'; import { LargeText } from '../text/Text.component'; import { CoreUITheme } from '../../style/theme'; +import { useHistory } from 'react-router'; type Props = { listedResource: { singular: string; @@ -12,7 +13,6 @@ type Props = { }; icon: IconName; link?: string; - history?: Record; backgroundColor?: keyof CoreUITheme; /** * The resource to create before browsing the listed resource @@ -46,14 +46,9 @@ export const ActionWrapper = styled.div` `; function EmptyState(props: Props) { - const { - icon, - listedResource, - link, - history, - resourceToCreate, - backgroundColor, - } = props; + const { icon, listedResource, link, resourceToCreate, backgroundColor } = + props; + const history = useHistory(); return ( - {history && ( + {link && (