File size: 322 Bytes
f5071ca
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { useEffect, useState } from 'react';

const useClickSameRoute = () => {
   const [sameRoute, setSameRoute] = useState(false);

   useEffect(() => window.scrollTo(0, 0), [sameRoute]);

   const handleSameRoute = () => setSameRoute((prev) => !prev);

   return handleSameRoute;
};

export default useClickSameRoute;