-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.d.ts
More file actions
34 lines (31 loc) · 1.03 KB
/
index.d.ts
File metadata and controls
34 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* Options for the useGeoLocation hook.
*/
export interface GeoLocationOptions {
/** An optional initial country code to bypass the API call. */
country?: string;
/** The optional API endpoint URL to use for fetching geolocation.
* @default 'https://api.country.is'
*/
api?: string;
}
/**
* The result object returned by the useGeoLocation hook
*/
export interface GeoLocationResult {
/** The two-letter country code (e.g., 'US'). Undefined while loading or if an error occurs. */
country?: string;
/** Contains an Error object if the API call failed; otherwise, false. */
error: Error | false;
/** True if the location data is currently being fetched; otherwise, false. */
isLoading: boolean;
}
/**
* A thin wrapper around the wonderful Country.is that gets your users' country (and nothing else) from their IP.
* @see https://country.is
* @param options Options for the useGeoLocation hook.
*/
declare function useGeoLocation(
options?: GeoLocationOptions
): GeoLocationResult;
export default useGeoLocation;