(feat) add redirect to home for handle navigate to / without remove params
This commit is contained in:
18
src/utils/redirect-to-home .ts
Normal file
18
src/utils/redirect-to-home .ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import { useLocation, useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
|
const RedirectToHome = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
navigate({
|
||||||
|
pathname: "/",
|
||||||
|
search: location.search,
|
||||||
|
});
|
||||||
|
}, [navigate, location.search]);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default RedirectToHome;
|
||||||
Reference in New Issue
Block a user