getSafeInfo
Returns the information associated with the Safe connected to the SafeProvider
.
Usage
_17import { useSafeInfo } from '@safe-global/safe-react-hooks'_17_17function SafeInfo() {_17 const { getSafeInfo } = useSafe()_17 const {_17 data,_17 // ..._17 } = getSafeInfo()_17_17 return (_17 <>_17 {data && JSON.stringify(data)}_17 </>_17 )_17}_17_17export default SafeInfo
Parameters
UseSafeInfoParams
Parameters to customize the hook behavior.
_10import { UseSafeInfoParams } from '@safe-global/safe-react-hooks'
config
(Optional)
- Type:
SafeConfig
The configuration used instead of the one from the nearest SafeProvider
.
_10import { config } from './config.ts'_10_10const result = getSafeInfo({_10 config_10})
Returns
UseSafeInfoReturnType
_10import { UseSafeInfoReturnType } from '@safe-global/safe-react-hooks'
TanStack Query documentation (opens in a new tab)
data
- Type:
SafeInfo
(opens in a new tab) - Default:
undefined
The last successfully resolved data for the query.
dataUpdatedAt
- Type:
number
The timestamp for when the query most recently returned the status
as 'success'
.
error
- Type:
null | TError
- Default:
null
The error object for the query, if an error was thrown.
errorUpdatedAt
- Type:
number
The timestamp for when the query most recently returned the status
as 'error'
.
errorUpdateCount
- Type:
number
The sum of all errors.
failureCount
- Type:
number
The failure count for the query.
Incremented every time the query fails.
Reset to 0
when the query succeeds.
failureReason
- Type:
null | TError
The failure reason for the query retry.
Reset to null
when the query succeeds.
fetchStatus
- Type:
'fetching' | 'idle' | 'paused'
fetching
Is true whenever the queryFn
is executing, which includes initial pending as well as background refetches.
paused
The query wanted to fetch, but has been paused.
idle
The query is not fetching.
See Network Mode (opens in a new tab) for more information.
isError
/ isPending
/ isSuccess
- Type:
boolean
The boolean variables derived from status
.
isFetched
- Type:
boolean
Will be true if the query has been fetched.
isFetchedAfterMount
- Type:
boolean
Will be true
if the query has been fetched after the component mounted.
This property can be used to not show any previously cached data.
isFetching
/ isPaused
- Type:
boolean
The boolean variables derived from fetchStatus
.
isLoading
- Type:
boolean
Is true
whenever the first fetch for a query is in-flight.
Is the same as isFetching && !isPending
.
isLoadingError
- Type:
boolean
Will be true
if the query failed while fetching for the first time.
isPlaceholderData
- Type:
boolean
Will be true
if the data shown is the placeholder data.
isRefetchError
- Type:
boolean
Will be true
if the query failed while refetching.
isRefetching
- Type:
boolean
Is true
whenever a background refetch is in-flight, which does not include initial 'pending'
.
Is the same as isFetching && !isPending
.
isStale
- Type:
boolean
Will be true
if the data in the cache is invalidated or if the data is older than the given staleTime
.
refetch
- Type:
(options: { throwOnError: boolean, cancelRefetch: boolean }) => Promise<UseQueryResult>
A function to manually refetch the query.
throwOnError
- When set to
true
, an error will be thrown if the query fails. - When set to
false
, an error will be logged if the query fails.
- When set to
cancelRefetch
- When set to
true
, a currently running request will be cancelled before a new request is made. - When set to
false
, no refetch will be made if there is already a request running. - Defaults to
true
- When set to
status
- Type:
'error' | 'pending' | 'success'
pending
if there's no cached data and no query attempt was finished yet.
error
if the query attempt resulted in an error. The corresponding error
property has the error received from the attempted fetch.
success
if the query has received a response with no errors and is ready to display its data. The corresponding data
property on the query is the data received from the successful fetch or if the query's enabled
property is set to false
and has not been fetched yet data
is the first initialData
supplied to the query on initialization.