new-react-location
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

new-react-location is a simple React hook that provides easy access to the user's geolocation. It returns the user's current position (longitude and latitude) or an error if the user denies location access. This package is designed to integrate seamlessly into your React applications, making it effortless to retrieve and manage geolocation data.


Installation
To install new-react-location, run the following command:

npm install new-react-location


Example
import React from 'react';
import useLocation from 'new-react-location';

function MyComponent() { const { position, error } = useLocation();

if (error) {
    return <div>Error: {error}</div>;
}

if (!position) {
    return <div>Loading...</div>;
}

return (
    <div>
        <h2>Your Location:</h2>
        <p>Latitude: {position.latitude}</p>
        <p>Longitude: {position.longitude}</p>
    </div>
);

}

export default MyComponent;

Readme

Keywords

none

Package Sidebar

Install

npm i new-react-location

Weekly Downloads

1

Version

1.1.0

License

ISC

Unpacked Size

9.06 kB

Total Files

11

Last publish

Collaborators

  • _anant_jindal_