Files
explore/lib/hooks/useIsSafeAddress.tsx
T
tom goriunovandGitHub c559061506 migrate to ReactQuery v5 (#1321)
* change signature of hooks

* isLoading -> isPending

* default error type

* dev tools props
2023-11-02 10:27:41 -03:00

26 lines
672 B
TypeScript

import { useQuery } from '@tanstack/react-query';
import config from 'configs/app';
import useFetch from 'lib/hooks/useFetch';
const feature = config.features.safe;
export default function useIsSafeAddress(hash: string | undefined): boolean {
const fetch = useFetch();
const { data } = useQuery({
queryKey: [ 'safe_transaction_api', hash ],
queryFn: async() => {
if (!feature.isEnabled || !hash) {
return Promise.reject();
}
return fetch(`${ feature.apiUrl }/${ hash }`, undefined, { omitSentryErrorLog: true });
},
enabled: feature.isEnabled && Boolean(hash),
refetchOnMount: false,
});
return Boolean(data);
}