1.0.0 • Published 3 years ago

@ziphooks/use-geolocation v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@ziphooks/use-geolocation

React Hook for get geolocation about client.

Installation

yarn

yarn add @ziphooks/use-geolocation

npm

npm i @ziphooks/use-geolocation

Usage

import React from "react";
import useGeolocation from "@ziphooks/use-geolocation";

function App() {
  const { lat, lon, reload } = useGeolocation();
  return (
    <>
      <h1>latitude: {lat}</h1>
      <h1>longitude: {lon}</h1>
      <button onClick={reload}>Reload</button>
    </>
  );
};

Return

Return valueTypeDescription
latNumberA number latitude of current geolocation
lonNumberA number longitude of current geolocation
reloadFunctionA function to reload geolocation