Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using expo start for development is breaking, Cannot read property 'rootedDetectionMethods' of null #219

Open
maniteja-emmadi opened this issue Dec 21, 2023 · 1 comment

Comments

@maniteja-emmadi
Copy link

maniteja-emmadi commented Dec 21, 2023

Hi there,

I am using expo start in the development phase, when I want to test the features like jail-monkey I do an expo prebuild to test that particular feature to not add the ios and android folders to git.

Here I am using a custom hook called useRootDetection. And I want to use JailMonkey only when it's available so I have written the code like the following.

import JailMonkey from "jail-monkey";
import { NativeModules } from "react-native";

const isJailMonkeyAvailable = Boolean(NativeModules.JailMonkey);

export default function useRootDetection() {
    const [isRooted, setIsRooted] = useState(false);
   
    useEffect(() => {
        isJailMonkeyAvailable && setIsRooted(JailMonkey.isJailBroken());
    }, []);

    return { isRooted }
}

So I'm getting the following error because of one small thing in jail-monkey.js

image

To resolve this, we have to make a small change to the jail-monkey.js file which is

// Add this (|| {}) to the export default and optional chaining (?.)
androidRootedDetectionMethods: JailMonkey.rootedDetectionMethods, // from this
androidRootedDetectionMethods: JailMonkey?.rootedDetectionMethods || {}, // to this

@crafterm @tommeier @aprct @hisankaran @sonicdoe
I request you to make this necessary change. Thanks.

@maniteja-emmadi
Copy link
Author

maniteja-emmadi commented Dec 21, 2023

Thanks y'all for considering, but I got it to work by using npm i patch-package. I didn't know that existed before this. Keeping this issue open, you can consider fixing it.

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

No branches or pull requests

1 participant