Skip to content

Commit 178851d

Browse files
committed
fix: redirect 404 page to /docs/
Fixes #3441 Updated NotFound component to automatically redirect users to /docs/ Signed-off-by: Dhruv Goyal <dhruv621999goyal@gmail.com>
1 parent 0027922 commit 178851d

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import {useEffect} from "react";
1+
import React, { useEffect } from 'react';
2+
import { useHistory } from '@docusaurus/router';
3+
4+
export default function NotFoundContent() {
5+
const history = useHistory();
26

3-
export default function NotFound() {
47
useEffect(() => {
5-
if (typeof window !== "undefined") {
6-
// immediate redirect without adding to browser history
7-
window.location.replace("/docs");
8-
}
9-
}, []);
8+
history.push('/docs/');
9+
}, [history]);
1010

11-
// render nothing (no content shown)
1211
return null;
13-
}
12+
}

0 commit comments

Comments
 (0)