New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-use

Package Overview
Dependencies
Maintainers
1
Versions
272
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-use - npm Package Compare versions

Comparing version 5.3.1 to 5.4.0

7

CHANGELOG.md

@@ -0,1 +1,8 @@

# [5.4.0](https://github.com/streamich/react-use/compare/v5.3.1...v5.4.0) (2019-02-19)
### Features
* add error and loading fields to useGeolocation ([6909a69](https://github.com/streamich/react-use/commit/6909a69))
## [5.3.1](https://github.com/streamich/react-use/compare/v5.3.0...v5.3.1) (2019-02-17)

@@ -2,0 +9,0 @@

3

lib/useGeolocation.d.ts
export interface GeoLocationSensorState {
loading: boolean;
accuracy: number;

@@ -10,4 +11,6 @@ altitude: number;

timestamp: number;
error?: Error | PositionError;
}
declare const useGeolocation: () => {
loading: boolean;
accuracy: null;

@@ -14,0 +17,0 @@ altitude: null;

7

lib/useGeolocation.js

@@ -6,2 +6,3 @@ "use strict";

const [state, setState] = react_1.useState({
loading: true,
accuracy: null,

@@ -21,2 +22,3 @@ altitude: null,

setState({
loading: false,
accuracy: event.coords.accuracy,

@@ -33,5 +35,6 @@ altitude: event.coords.altitude,

};
const onEventError = (error) => mounted && setState(oldState => (Object.assign({}, oldState, { loading: false, error })));
react_1.useEffect(() => {
navigator.geolocation.getCurrentPosition(onEvent);
watchId = navigator.geolocation.watchPosition(onEvent);
navigator.geolocation.getCurrentPosition(onEvent, onEventError);
watchId = navigator.geolocation.watchPosition(onEvent, onEventError);
return () => {

@@ -38,0 +41,0 @@ mounted = false;

{
"name": "react-use",
"version": "5.3.1",
"version": "5.4.0",
"description": "Collection of React Hooks",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc