Closed mljlynch closed 1 year ago
This package does not call Double
doubleValue
method once, I doubt the issue came from this library. I'm closing this because of that (+ there's no clear way to reproduce the issue)
Note that you could simplify your code a bit:
import * as React from 'react';
import {Platform} from 'react-native';
import {check, PERMISSIONS, PermissionStatus} from 'react-native-permissions';
const PermissionsContext = React.createContext<{camera?: PermissionStatus}>({});
export const usePermissions = () => React.useContext(PermissionsContext);
export const PermissionsProvider: React.FC<{children: React.ReactNode}> = ({children}) => {
const [camera, setCamera] = React.useState<PermissionStatus>();
const permissions = React.useMemo(() => ({camera}), [camera]);
React.useEffect(() => {
check(Platform.select({android: PERMISSIONS.ANDROID.CAMERA, default: PERMISSIONS.IOS.CAMERA}))
.then((status) => setCamera(status))
.catch((_error) => setCamera('unavailable'));
}, []);
return <PermissionsContext.Provider value={permissions}>{children}</PermissionsContext.Provider>;
};
To understand the need to memo your provider value: https://stackoverflow.com/a/62231233
This repros with the cleaned up code. I will try to get you a repro in the sample app.
Bug summary
I recently moved my permissions checker to a context from a hook, so that the state would persist on update.
Here is my code
When building via CI (so not deploying via USB connection and wifi), the android app repeatedly crashes on load with an error:
Any help would be greatly appreciated 🙏🏼
Library version
3.6.1
Environment info
Steps to reproduce
Listed in the description
Reproducible sample code
Listed in the description