我在React Native中有一个巨大的应用程序,目前我正致力于仅在Android上构建它。我必须升级react-native版本> = 0.59,以使其与适用于64位设备的新Google政策兼容,因为我无法再在Play商店上更新我的应用了。但是,我花了很多时间来更新现有应用程序中的react-native版本,但尝试了大约2天,但这很头疼,而且效果不理想。
现在我正在做的是,我创建了一个新的react-native应用程序,该应用程序基于最新的react-native版本0.60.4构建。我将所有代码从现有应用程序复制到了包括index.js的新应用程序中。但是在进行任何更改之前,代码可以正常工作,但是当我将以前的代码转移到新应用后,它便停止工作。我解决了大多数错误,但现在却出现如下错误:
TypeError: Object is not a function (near '...(0,S.default)...')
│
│ This error is located at:
│ in Te
│ in f
│ in RCTView
│ in RCTView
└ in c
我以前的代码是最新的并且可以正常工作。从上面的错误中,我无法确定实际问题在哪里以及什么。请在这里帮助我。
我的index.js:
const Navigation = () => StackNavigator(
{
SplashScreen: {screen : SplashScreen},
MapScreen:{screen:MapScreen},
// Login screens
SignUpScreen: {screen : SignUpScreen},
},
{
initialRouteName: 'SplashScreen',
transitionConfig,
headerMode: 'none',
navigationOptions: {
headerVisible: false
}
}
);
class MyApp extends React.Component {
render() {
console.log('this.props in MyApp SplashScreen', this.props); // This will list the initialProps.
return <Navigation screenProps={this.props} />;
}
}
AppRegistry.registerComponent(appName, () => MyApp);
我的initialRouteScreen是SplashScreen,如下所示:
import {StackNavigator} from 'react-navigation';
import React, {Component} from 'react';
import {Platform, AsyncStorage,Picker,StyleSheet,TextInput,Dimensions,Linking, ToastAndroid,Text, View, Image,TouchableOpacity,TouchableWithoutFeedback} from 'react-native';
import Colors from '../utils/Res/Colors';
import Strings from '../utils/Res/Strings';
import * as Animatable from 'react-native-animatable';
import {DeviceEventEmitter, NativeModules} from 'react-native';
import ApiService from '../network/ApiService';
import CustomDialog from '../customViews/dialog/CustomDialog';
var FCM = NativeModules.FCM;
type Props = {};
export default class SplashScreen extends Component<Props>
{
constructor(args) {
super(args);
let { width } = Dimensions.get("window");
apiService = new ApiService();
this.state = {
screenWidth: width,
userPIN:'',
showUpdateDialog:false,
isUpdateAvailabe:false,
}
}
componentWillMount(){
FCM.getAppVersion((update) => {
if(update){
this.setState({showUpdateDialog:true});
this.setState({isUpdateAvailabe:true});
}
// console.log("SplashScreen", "componentWillMount getAppVersion : " + update);
});
}
componentDidUnmount(){
DeviceEventEmitter.removeListener(Strings.fingerPrintEventName, this.listener)
}
componentDidMount(){
console.log("SplashScreen", "componentDidMount Props: " + this.props.screenProps.DeepLink_TransactionID);
this.listener = DeviceEventEmitter.addListener(Strings.fingerPrintEventName, response => {
console.log("Event Listener called : " + response);
if(response === 1){
this.props.navigation.replace("HomeScreen", {data: this.props.screenProps.notification})
} else {
ToastAndroid.show("Fingerprint detection falied", ToastAndroid.SHORT);
}
});
// if (this.props.screenProps.notification){
// console.log("SplashScreen", "componentDidMount Props notification: " + this.props.screenProps.notification);
// } else {
// console.log("SplashScreen", "componentDidMount Props no notification");
// }
this.refs.viewLogo.fadeOutLeft(5);
setTimeout(()=>{
this.refs.viewLogo.zoomIn(700);
}, 100);
this.timeoutHandle = setTimeout(()=>{
this.getUserData();
}, 2500);
}
componentWillUnmount(){
clearTimeout(this.timeoutHandle);
}
getUserData(){
if(this.state.isUpdateAvailabe){
return;
}
AsyncStorage.multiGet([Strings.prefLoginID, Strings.prefFingerPrintEnable, Strings.prefUserPIN]).then(response => {
if (response[0][1] === null || response[0][1] === 'null' || response[0][1] === undefined || response[0][1] === '') {
AsyncStorage.setItem(Strings.prefIsFirstTime, "" + true);
this.props.navigation.replace("SignUpScreen", {data: this.props.screenProps.notification})
} else {
AsyncStorage.setItem(Strings.prefIsFirstTime, "" + false);
if(response[1][1] === "true"){
var user_pin = response[2][1];
FCM.isDeviceCompatible((response) => {
if(response === true){
FCM.isFingerPrintAvailable((response) => {
console.log("isFingerPrintAvailable response : " + response);
if(response === true){
FCM.buildBioMetric(true);
} else {
ToastAndroid.show("Add Fingerprint to your device Settings", ToastAndroid.SHORT);
}
});
} else {
if (user_pin != null && user_pin != undefined && user_pin != ""){
this.props.navigation.replace("AuthenticatePINScreen", {data: this.props.screenProps.notification})
} else {
this.props.navigation.replace("HomeScreen", {data: this.props.screenProps.notification})
}
}
});
} else {
this.props.navigation.replace("HomeScreen", {data: this.props.screenProps.notification})
}
}
})
}
onDialogOkClick(){
console.log("onDialogOkClick");
this.setState({showUpdateDialog:false});
Linking.openURL("market://details?id=com.m_naira");
}
render() {
return (
<View style={styles.root}>
<View style = {{flex:1}}>
<View style = {{width:this.state.screenWidth,flex:1,position:'absolute',marginTop:130,marginBottom:30,justifyContent:'center',alignItems:'center'}}>
<Text style={styles.TitleMessageTextStyle}>m-naira</Text>
<Text style={styles.MessageTextStyle}>{Strings.splashMessage}</Text>
</View>
<View style = {{flex:1,justifyContent:'center',alignItems:'center'}}>
<Animatable.Image ref="viewLogo" style={styles.LogoImageStyle} source={require('../images/ic_launcher.png')}/>
</View>
</View>
{<CustomDialog message = {Strings.msgAppUpdate} showCancel = {false} okText = {"UPDATE"} onOkPress = {() => {this.onDialogOkClick()}} visibility = {this.state.showUpdateDialog}/>}
</View>
);
}
}
const styles = StyleSheet.create({
root: {
flex: 1,
backgroundColor: Colors.appBGColor
},
LogoImageStyle: {width:150, height:150},
MessageTextStyle: {width:280,textAlign:"center",color:Colors.appColor,fontSize:14},
TitleMessageTextStyle: {width:200,textAlign:"center",color:Colors.appColor,fontSize:20,fontWeight:"bold"}
});
package.json:
{
"name": "mNairaUpgrade",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start",
"test": "jest",
"lint": "eslint .",
"android": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && react-native run-android",
"ios": "react-native run-ios"
},
"dependencies": {
"axios": "^0.19.0",
"moment": "^2.24.0",
"react": "16.8.6",
"react-image-mapper": "0.0.14",
"react-moment": "^0.9.2",
"react-native": "0.60.4",
"react-native-animatable": "^1.3.2",
"react-native-autocomplete-input": "^4.1.0",
"react-native-camera": "^3.1.1",
"react-native-contacts": "^5.0.2",
"react-native-datepicker-dialog": "0.0.9",
"react-native-geocoder": "^0.5.0",
"react-native-gesture-handler": "^1.3.0",
"react-native-google-places-autocomplete": "^1.3.9",
"react-native-image-crop-picker": "^0.25.0",
"react-native-maps": "^0.25.0",
"react-native-qrcode": "^0.2.7",
"react-native-qrcode-scanner": "^1.2.1",
"react-native-qrcode-svg": "^5.1.2",
"react-native-scan-barcode": "^3.1.5",
"react-native-signature-capture": "^0.4.9",
"react-native-svg": "^9.6.2",
"react-navigation": "^3.11.1",
"url-search-params": "^1.1.0"
},
"devDependencies": {
"@babel/core": "7.5.5",
"@babel/runtime": "7.5.5",
"@react-native-community/eslint-config": "0.0.3",
"babel-jest": "24.8.0",
"eslint": "6.1.0",
"jest": "24.8.0",
"metro-react-native-babel-preset": "0.54.1",
"react-test-renderer": "16.8.6"
},
"jest": {
"preset": "react-native"
}
}
任何帮助将不胜感激。谢谢