mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-09-24 23:01:18 +08:00
fix(types): adding correct redirect-home props to fix some ts-ignores (#50810)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
co-authored by
Oliver Eyton-Williams
parent
8d12376931
commit
ebc9343e8f
@@ -1,8 +1,8 @@
|
||||
/* eslint-disable react/display-name */
|
||||
import { navigate } from 'gatsby';
|
||||
import type { RouteComponentProps } from '@reach/router';
|
||||
|
||||
const createRedirect =
|
||||
(to = '/'): (() => JSX.Element | null) =>
|
||||
(to = '/'): ((_props: RouteComponentProps) => JSX.Element | null) =>
|
||||
() => {
|
||||
if (typeof window !== 'undefined') {
|
||||
void navigate(to);
|
||||
|
||||
@@ -16,9 +16,8 @@ function Certification(): JSX.Element {
|
||||
// @ts-ignore
|
||||
path={withPrefix('/certification/:username/:certSlug')}
|
||||
/>
|
||||
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
|
||||
{/* @ts-ignore */}
|
||||
<RedirectHome default={true} />
|
||||
|
||||
<RedirectHome default />
|
||||
</Router>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,9 +9,8 @@ function Settings(): JSX.Element {
|
||||
return (
|
||||
<Router>
|
||||
<ShowSettings path={withPrefix('/settings')} />
|
||||
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
|
||||
{/* @ts-ignore */}
|
||||
<RedirectHome default={true} />
|
||||
|
||||
<RedirectHome default />
|
||||
</Router>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,9 +14,8 @@ function Unsubscribed(): JSX.Element {
|
||||
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
|
||||
{/* @ts-ignore */}
|
||||
<ShowUnsubscribed path={withPrefix('/unsubscribed')} />
|
||||
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
|
||||
{/* @ts-ignore */}
|
||||
<RedirectHome default={true} />
|
||||
|
||||
<RedirectHome default />
|
||||
</Router>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,9 +10,8 @@ function User(): JSX.Element {
|
||||
<Router>
|
||||
{/* @ts-expect-error Adding path property breaks username typing */}
|
||||
<ShowUser path={withPrefix('/user/:username/report-user')} />
|
||||
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
|
||||
{/* @ts-ignore */}
|
||||
<RedirectHome default={true} />
|
||||
|
||||
<RedirectHome default />
|
||||
</Router>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user