@reactuses/core 6.1.11 → 6.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1351,7 +1351,11 @@ function useSupported(callback, sync = false) {
1351
1351
  const [supported, setSupported] = React.useState(false);
1352
1352
  const effect = sync ? useIsomorphicLayoutEffect : React.useEffect;
1353
1353
  effect(()=>{
1354
- setSupported(Boolean(callback()));
1354
+ try {
1355
+ setSupported(Boolean(callback()));
1356
+ } catch (e) {
1357
+ setSupported(false);
1358
+ }
1355
1359
  }, []);
1356
1360
  return supported;
1357
1361
  }
@@ -1682,7 +1686,7 @@ const initCoord = {
1682
1686
  };
1683
1687
  const useGeolocation = (options = defaultOptions$1)=>{
1684
1688
  const { enableHighAccuracy = true, maximumAge = 30000, timeout = 27000 } = options;
1685
- const isSupported = useSupported(()=>navigator && 'geolocation' in navigator);
1689
+ const isSupported = useSupported(()=>typeof navigator !== 'undefined' && !!navigator.geolocation && typeof navigator.geolocation.getCurrentPosition === 'function' && typeof navigator.geolocation.watchPosition === 'function' && typeof navigator.geolocation.clearWatch === 'function');
1686
1690
  const [coordinates, setCoordinates] = React.useState(initCoord);
1687
1691
  const [locatedAt, setLocatedAt] = React.useState(null);
1688
1692
  const [error, setError] = React.useState(null);
package/dist/index.mjs CHANGED
@@ -1343,7 +1343,11 @@ function useSupported(callback, sync = false) {
1343
1343
  const [supported, setSupported] = useState(false);
1344
1344
  const effect = sync ? useIsomorphicLayoutEffect : useEffect;
1345
1345
  effect(()=>{
1346
- setSupported(Boolean(callback()));
1346
+ try {
1347
+ setSupported(Boolean(callback()));
1348
+ } catch (e) {
1349
+ setSupported(false);
1350
+ }
1347
1351
  }, []);
1348
1352
  return supported;
1349
1353
  }
@@ -1674,7 +1678,7 @@ const initCoord = {
1674
1678
  };
1675
1679
  const useGeolocation = (options = defaultOptions$1)=>{
1676
1680
  const { enableHighAccuracy = true, maximumAge = 30000, timeout = 27000 } = options;
1677
- const isSupported = useSupported(()=>navigator && 'geolocation' in navigator);
1681
+ const isSupported = useSupported(()=>typeof navigator !== 'undefined' && !!navigator.geolocation && typeof navigator.geolocation.getCurrentPosition === 'function' && typeof navigator.geolocation.watchPosition === 'function' && typeof navigator.geolocation.clearWatch === 'function');
1678
1682
  const [coordinates, setCoordinates] = useState(initCoord);
1679
1683
  const [locatedAt, setLocatedAt] = useState(null);
1680
1684
  const [error, setError] = useState(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactuses/core",
3
- "version": "6.1.11",
3
+ "version": "6.1.12",
4
4
  "license": "Unlicense",
5
5
  "homepage": "https://www.reactuse.com/",
6
6
  "repository": {