mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-17 16:00:50 -04:00
14 lines
333 B
TypeScript
14 lines
333 B
TypeScript
import { navigate } from 'gatsby';
|
|
import type { RouteComponentProps } from '@gatsbyjs/reach-router';
|
|
|
|
const createRedirect =
|
|
(to = '/'): ((_props: RouteComponentProps) => JSX.Element | null) =>
|
|
() => {
|
|
if (typeof window !== 'undefined') {
|
|
void navigate(to);
|
|
}
|
|
return null;
|
|
};
|
|
|
|
export default createRedirect;
|