user-location-address
v0.0.3
Published
Module to return the user's location (full address) with just one click by the user, if he authorizes it. Written in TypeScript, documented, tested and maintained. Disclaimer: at least React 16 is needed (the one with hooks)
Downloads
14
Maintainers
Readme
user-location-address
Installation
npm i user-location-addressor
yarn add user-location-addressUsage
This hook returns the userLocation, latitude, longitude, isLoading, userClickToGetLocation. This hook also includes the insertion of the user's city, state and country in Local Storage.
import { useUserLocation } from "user-location-address";
return (
const { userClickToGetLocation, userLocation, isLoading } = useUserLocation();
// Passing data as properties to a button component.
<LocationButton
onClick={userClickToGetLocation}
userLocation={userLocation}
isLoading={isLoading}
/>
);Hook return
| Name | Type | Description |
| ---------------------- | --------- | ----------------------------- |
| userLocation | object | User address return |
| latitude | number | User's latitude |
| longitude | number | User's longitude |
| isLoading | boolean | Data loading process |
| userClickToGetLocation | func | Executes the data return call |
License
The files included in this repository are licensed under the MIT license.
Contributions
Feel free to open an issue or add a pull request. Anytime. Really, I mean it.
