Cannot read property 'currentVersion' of null
pk936 opened this issue · comments
- Install this library.
- Added following code in useEffect
- Ran command - npm run android
- Console error [TypeError: Cannot read property 'currentVersion' of null]
useEffect(() => {
checkUpdateNeeded();
});
const checkUpdateNeeded = async () => {
try {
let updateNeeded = await VersionCheck.needUpdate();
if (updateNeeded.isNeeded) {
Alert.alert("Please Update",
"A new version of the app is available.",
[
{
text: "Update",
onPress: () => {
BackHandler.exitApp();
Linking.openURL(updateNeeded.storeUrl)
}
}
])
}
} catch (error) {
}
}
It's fixed.
I ran
- react-native link
- cd android && ./gradlew clean
- npm run android
react-native link not working magically for me. What I did is follow manually linking process. Found under my android folder I did miss set up setting inside android/settings.gradle. Once I added contents inside it, then rebuild android app again, the needUpdate function returned expected response object to me.