Skip to content

useGeolocation: Check for support not robust enough#191

Merged
childrentime merged 1 commit intochildrentime:mainfrom
brandoningli:pr/robust-geolocation-check
Mar 5, 2026
Merged

useGeolocation: Check for support not robust enough#191
childrentime merged 1 commit intochildrentime:mainfrom
brandoningli:pr/robust-geolocation-check

Conversation

@brandoningli
Copy link
Contributor

We've been running into an issue where we're getting an error that undefined is not an object when evaluating navigator.geolocation.getCurrentPosition in the useGeolocation hook. It turns out that the current check for support is not robust enough.

This PR introduces a more extensive check to make sure the requisite functions are actually provided by the browser before attempting to use them. It also adds a try/catch to useSupportedto treat anything that throws an error as failing the support check.

I've patched this check into my codebase and it seems to resolve the issue we're having.

@childrentime childrentime self-requested a review March 5, 2026 00:36
childrentime added a commit that referenced this pull request Mar 5, 2026
Co-Authored-By: brandoningli <6826623+brandoningli@users.noreply.github.com>
childrentime added a commit that referenced this pull request Mar 5, 2026
Co-Authored-By: brandoningli <6826623+brandoningli@users.noreply.github.com>
childrentime added a commit that referenced this pull request Mar 5, 2026
Co-Authored-By: brandoningli <6826623+brandoningli@users.noreply.github.com>
@childrentime childrentime merged commit a25a80a into childrentime:main Mar 5, 2026
3 of 6 checks passed
@childrentime
Copy link
Owner

Thank you, I'll release a new version later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants