mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	Fix useInstance hook (#5567)
This commit is contained in:
		| @@ -21,8 +21,12 @@ export function useInstance( | ||||
|  | ||||
|   const instanceQuery = useQuery({ | ||||
|     queryKey: ['instance', url, pk, params], | ||||
|     enabled: pk != null && pk != undefined && pk.length > 0, | ||||
|     queryFn: async () => { | ||||
|       if (pk == null || pk == undefined || pk.length == 0) { | ||||
|         setInstance({}); | ||||
|         return null; | ||||
|       } | ||||
|  | ||||
|       return api | ||||
|         .get(url + pk + '/', { | ||||
|           params: params | ||||
| @@ -47,12 +51,9 @@ export function useInstance( | ||||
|     refetchOnWindowFocus: false | ||||
|   }); | ||||
|  | ||||
|   const refreshInstance = useCallback( | ||||
|     function () { | ||||
|       instanceQuery.refetch(); | ||||
|     }, | ||||
|     [instanceQuery] | ||||
|   ); | ||||
|   const refreshInstance = useCallback(function () { | ||||
|     instanceQuery.refetch(); | ||||
|   }, []); | ||||
|  | ||||
|   return { instance, refreshInstance, instanceQuery }; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user