Prior Issues
None found. #1563 is about Safari not firing the change event, which is a different problem.
What is the current behavior?
usePermission calls navigator.permissions.query() inside its effect without checking that the Permissions API exists:
https://github.com/react-hookz/web/blob/master/src/usePermission/index.ts
navigator.permissions
.query(descriptor)
.then((status): void => { ... });
In environments where navigator.permissions is undefined, the effect throws:
TypeError: Cannot read properties of undefined (reading 'query')
We see this in production logs from Android WebView.
Steps to Reproduce
Render a component using the hook in any environment without the Permissions API.
What is the expected behavior?
The hook should never throw. When the API is missing it should report that instead (for example a dedicated 'unsupported' state), so apps can degrade gracefully.
Environment Details
@react-hookz/web version: 26.1.0
react version: 19.2.5
react-dom version: 19.2.5
typescript version: 5.x
- OS: Android (also reproducible on iOS < 16)
- Browser: Android WebView, iOS Safari 15
- Did this work in previous versions? No, the call has been unguarded since the hook was added
Prior Issues
None found. #1563 is about Safari not firing the
changeevent, which is a different problem.What is the current behavior?
usePermissioncallsnavigator.permissions.query()inside its effect without checking that the Permissions API exists:https://github.com/react-hookz/web/blob/master/src/usePermission/index.ts
In environments where
navigator.permissionsisundefined, the effect throws:We see this in production logs from Android WebView.
Steps to Reproduce
Render a component using the hook in any environment without the Permissions API.
What is the expected behavior?
The hook should never throw. When the API is missing it should report that instead (for example a dedicated
'unsupported'state), so apps can degrade gracefully.Environment Details
@react-hookz/webversion: 26.1.0reactversion: 19.2.5react-domversion: 19.2.5typescriptversion: 5.x