Skip to content

Commit

Permalink
call useHistory in EmptyState and remove history from props
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanMarcMilletScality committed Jun 6, 2024
1 parent af8f715 commit 5bb6839
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/lib/components/emptystate/Emptystate.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ 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;
plural: string;
};
icon: IconName;
link?: string;
history?: Record<string, any>;
backgroundColor?: keyof CoreUITheme;
/**
* The resource to create before browsing the listed resource
Expand Down Expand Up @@ -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 (
<EmptystateContainer
className="sc-emptystate"
Expand All @@ -72,7 +67,7 @@ function EmptyState(props: Props) {
: `Before browsing your ${listedResource.plural}, create your first ${resourceToCreate}.`}
</LargeText>
</EmptyStateRow>
{history && (
{link && (
<ActionWrapper>
<Button
label={`Create ${resourceToCreate || listedResource.singular}`}
Expand Down

0 comments on commit 5bb6839

Please sign in to comment.