Create ESLint rule to discourage usage of navigate() and prefer Link (#5642)
### Description Create ESLint rule to discourage usage of navigate() and prefer Link ### Refs #5468 ### Demo   Fixes #5468 --------- Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { IconChevronLeft } from 'twenty-ui';
|
||||
|
||||
import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink';
|
||||
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
|
||||
|
||||
type NavigationDrawerBackButtonProps = {
|
||||
@ -36,22 +36,19 @@ export const NavigationDrawerBackButton = ({
|
||||
title,
|
||||
}: NavigationDrawerBackButtonProps) => {
|
||||
const theme = useTheme();
|
||||
const navigate = useNavigate();
|
||||
const navigationMemorizedUrl = useRecoilValue(navigationMemorizedUrlState);
|
||||
|
||||
return (
|
||||
<StyledContainer>
|
||||
<StyledIconAndButtonContainer
|
||||
onClick={() => {
|
||||
navigate(navigationMemorizedUrl, { replace: true });
|
||||
}}
|
||||
>
|
||||
<IconChevronLeft
|
||||
size={theme.icon.size.md}
|
||||
stroke={theme.icon.stroke.lg}
|
||||
/>
|
||||
<span>{title}</span>
|
||||
</StyledIconAndButtonContainer>
|
||||
<UndecoratedLink to={navigationMemorizedUrl} replace>
|
||||
<StyledIconAndButtonContainer>
|
||||
<IconChevronLeft
|
||||
size={theme.icon.size.md}
|
||||
stroke={theme.icon.stroke.lg}
|
||||
/>
|
||||
<span>{title}</span>
|
||||
</StyledIconAndButtonContainer>
|
||||
</UndecoratedLink>
|
||||
</StyledContainer>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user