MCPcopy Create free account
hub / github.com/dailydotdev/apps / GoBackButton

Function GoBackButton

packages/shared/src/components/post/GoBackHeaderMobile.tsx:19–69  ·  view source on GitHub ↗
({
  className,
  showLogo = true,
  compactLogo = false,
  fallbackPath,
}: WithClassNameProps & {
  showLogo?: boolean;
  compactLogo?: boolean;
  fallbackPath?: string;
})

Source from the content-addressed store, hash-verified

17import { useHideOnScrollDown } from '../../features/getApp/hooks/useHideOnScrollDown';
18
19export const GoBackButton = ({
20 className,
21 showLogo = true,
22 compactLogo = false,
23 fallbackPath,
24}: WithClassNameProps & {
25 showLogo?: boolean;
26 compactLogo?: boolean;
27 fallbackPath?: string;
28}): JSX.Element | null => {
29 const router = useRouter();
30 const goHome = useCallback(() => router.push('/'), [router]);
31 const featureTheme = useFeatureTheme();
32
33 const canGoBack = canGoBackInApp();
34
35 const goBack = useCallback(() => {
36 if (canGoBack) {
37 router.back();
38 return;
39 }
40
41 if (fallbackPath) {
42 router.push(fallbackPath);
43 }
44 }, [canGoBack, fallbackPath, router]);
45
46 const logoButton = showLogo ? (
47 <Logo
48 className="my-2"
49 compact={compactLogo}
50 onLogoClick={goHome}
51 position={LogoPosition.Initial}
52 featureTheme={featureTheme}
53 />
54 ) : null;
55
56 return canGoBack || fallbackPath ? (
57 <Button
58 icon={<ArrowIcon className="-rotate-90" />}
59 size={ButtonSize.Small}
60 variant={ButtonVariant.Tertiary}
61 onClick={goBack}
62 className={className}
63 type="button"
64 aria-label="Go back"
65 />
66 ) : (
67 logoButton
68 );
69};
70
71interface GoBackHeaderMobileProps extends WithClassNameProps {
72 title?: string;

Callers

nothing calls this directly

Calls 5

useFeatureThemeFunction · 0.90
canGoBackInAppFunction · 0.90
pushMethod · 0.80
backMethod · 0.80
useRouterFunction · 0.50

Tested by

no test coverage detected