Reputation: 267
I am attempting to convert my react-native project into an expo project, one small issue I've encountered is when I run the expo project I get an error as such
null is not an object (evaluating 'RCTToastAndroid.SHORT')
After doing some research online on how to fix this problem a user requested that a problem like this can simply be resolved by removing the Android
part of RCTToastAndroid.SHORT
this user stated that RCTToast
is universally compatible with both iOS and Android. However when I do this I receive an error saying null is not an object (evaluating 'RCTToast.SHORT')
What can I do that will help ease the transition from my react-native project to an expo project?
Upvotes: 2
Views: 3822
Reputation: 81
I had the same exact problem.
Check to see if you've imported a library called 'react-native-simple-toast'. Remove it from your dependencies.
According to this issue:
this library has a custom native module for ios, and expo does not support that. This lib will not work with expo
it will only work with a bare React Native project.
Here's a library that will work with Expo on both Android and iOS. The only downside is that it's pure Javascript.
You can use it like this:
import Toast from 'react-native-root-toast'
Toast.show('Your message here', {
duration: Toast.durations.SHORT,
position: Toast.positions.BOTTOM,
shadow: true,
animation: true
});
Upvotes: 0
Reputation: 143
only do like this
import {ToastAndroid}from 'react-native '
return ToastAndroid.show("some error msg", ToastAndroid.LONG);
Upvotes: 1
Reputation: 1102
All apps created with create-react-native-app, are compatible with Expo CLI without changes.
Upvotes: 1