mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	Debounce checkLoginState to prevent unexpected redirection during testing (#9012)
				
					
				
			This commit is contained in:
		| @@ -1,5 +1,6 @@ | |||||||
| import { Trans } from '@lingui/macro'; | import { Trans } from '@lingui/macro'; | ||||||
| import { Card, Container, Group, Loader, Stack, Text } from '@mantine/core'; | import { Card, Container, Group, Loader, Stack, Text } from '@mantine/core'; | ||||||
|  | import { useDebouncedCallback } from '@mantine/hooks'; | ||||||
| import { useEffect } from 'react'; | import { useEffect } from 'react'; | ||||||
| import { useLocation, useNavigate } from 'react-router-dom'; | import { useLocation, useNavigate } from 'react-router-dom'; | ||||||
|  |  | ||||||
| @@ -9,8 +10,10 @@ export default function Logged_In() { | |||||||
|   const navigate = useNavigate(); |   const navigate = useNavigate(); | ||||||
|   const location = useLocation(); |   const location = useLocation(); | ||||||
|  |  | ||||||
|  |   const checkLoginStateDebounced = useDebouncedCallback(checkLoginState, 300); | ||||||
|  |  | ||||||
|   useEffect(() => { |   useEffect(() => { | ||||||
|     checkLoginState(navigate, location?.state); |     checkLoginStateDebounced(navigate, location?.state); | ||||||
|   }, [navigate]); |   }, [navigate]); | ||||||
|  |  | ||||||
|   return ( |   return ( | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user