stripe-react-native: StripeProvider - TypeError: Cannot read property 'getConstants' of null, js engine: hermes
Describe the bug Although I have installed stripe-react-native as specified in documentation, The inclusion of <StripeProvider> results in the following error on app build: “TypeError: Cannot read property ‘getConstants’ of null, js engine: hermes”. I’m running iOS react-native with version “@stripe/stripe-react-native”: “0.28.0”.
Any help is greatly appreciated, thanks.
Code
import {NavigationContainer, useNavigation} from '@react-navigation/native';
import React, {useEffect, useState} from 'react';
import EntryPage from './screens/entry-page';
import HomePage from './screens/home-page';
import ProfilePage from './screens/profile-page';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import {Auth} from 'aws-amplify';
import {Button, StyleSheet, View} from 'react-native';
import {StripeProvider} from '@stripe/stripe-react-native';
const Stack = createNativeStackNavigator();
function App(): JSX.Element {
const [user, setUser] = useState(null);
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
checkAuth();
}, []);
// immediately check if user is logged on
const checkAuth = async () => {
try {
const user = await Auth.currentAuthenticatedUser();
setUser(user);
} catch (error) {
setUser(null);
}
setIsLoading(false);
};
if (isLoading) {
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
});
return <View style={styles.container} />;
} else {
return (
<StripeProvider publishableKey={'{I include my publishable key here as string'}>
<NavigationContainer>
<Stack.Navigator initialRouteName={user ? 'HomePage' : 'EntryPage'}>
<Stack.Screen
name="HomePage"
component={HomePage}
options={({navigation}) => ({
headerShown: true,
// headerStyle: {
// backgroundColor: 'black',
// },
headerTransparent: true,
headerBlurEffect: 'systemUltraThinMaterialLight',
headerBackVisible: false,
headerRight: () => (
<Button
onPress={() => navigation.navigate('Profile')}
title="Profile"
color="gray"
/>
),
})}
initialParams={{userLoggedIn: user ? true : false}}
/>
<Stack.Screen
name="EntryPage"
component={EntryPage}
options={({navigation}) => ({
headerShown: false,
})}
/>
<Stack.Screen
name="Profile"
component={ProfilePage}
options={({navigation}) => ({
headerShown: false,
})}
/>
</Stack.Navigator>
</NavigationContainer>
</StripeProvider>
);
}
}
export default App;
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 3
- Comments: 15
Having this issue when trying
jest.requireActual('@stripe/stripe-react-native')
TypeError: Cannot read properties of undefined (reading 'getConstants')
I just rebuild the app and the error was gone.
eas build --profile development --platform ios
Still having this issue running the latest version of stripe-react-native and expo. I’ve cleared cache, removed all the node modules, and lock files.
I am facing this same issue with same set up 🤔
Was there anything additional that you did?
I tried the following steps and your last suggestion, but am getting the same result.
rm yarn.lock rm node_modelules yarn install
cd ios rm Podfile.lock rm -rf Pods pod install
I also did a Clean Build Folder in XCode… and npx react-native start --reset-cache
but still am facing this error.