others - Javascript -TypeError: undefined is not an object (evaluating 'ReactSharedInternals.hasOwnProperty')

85 1

我正在構建自己第一個React Native應用程序,

react-native link <library-here>

這是我的src/package.json


{


"name":"src",


"version":"0.0.1",


"private": true,


"scripts": {


"android":"react-native run-android",


"ios":"react-native run-ios",


"start":"react-native start",


"test":"jest",


"lint":"eslint ."


 },


"dependencies": {


"expo-image-picker":"^8.0.0",


"react":"^16.0.0-alpha.12",


"react-native":"0.61.5",


"react-native-screens":"^2.0.0-alpha.19",


"react-navigation":"2.14.0",


"react-navigation-stack":"^1.10.3"


 },


"devDependencies": {


"@babel/core":"^7.7.5",


"@babel/runtime":"^7.7.5",


"@react-native-community/eslint-config":"^0.0.5",


"babel-jest":"^24.9.0",


"eslint":"^6.7.2",


"jest":"^24.9.0",


"metro-react-native-babel-preset":"^0.57.0",


"react-test-renderer":"16.9.0"


 },


"jest": {


"preset":"react-native"


 }


}



,下面是我的package.json,在我的項目root中,更改了react-navigation:


{


"dependencies": {


"react-native-gesture-handler":"^1.5.2",


"react-native-reanimated":"^1.4.0",


"react-native-screens":"^2.0.0-alpha.19",


"react-navigation":"^4.0.10"


 }


}



如果需要,這是我的AppNavigator.js,我在App.js中調用:


import { createAppContainer, createSwitchNavigator } from"react-navigation";


import { createStackNavigator } from"react-navigation";


import { Platform } from"react-native";


// Importing my screens here.


import LoginCreateAccountScreen from"../screens/LoginCreateAccountScreen";


import CreateAccountScreen from"../screens/CreateAccountScreen";


import LoginScreen from"../screens/LoginScreen";


import SplashScreen from"../screens/SplashScreen";



const MainNavigator = createStackNavigator({


 SplashScreen: {screen: SplashScreen},


 LoginCreateAccountScreen: {screen: LoginCreateAccountScreen},


 LoginScreen: {screen: LoginScreen},


 CreateAccountScreen: {screen: CreateAccountScreen},


});



export default createAppContainer(


 createSwitchNavigator(


 {


 // You could add another route here for authentication.


 // Read more at https://reactnavigation.org/docs/en/auth-flow.html


 SplashScreen: SplashScreen,


 LoginCreateAccountScreen: LoginCreateAccountScreen,


 LoginScreen: LoginScreen,


 CreateAccountScreen: CreateAccountScreen


 },


 {


 initialRouteName: 'SplashScreen' // Entry


 }


 )


);



我的App.js


import React, { Component } from 'react';


import AppNavigator from './navigation/AppNavigator';



export default class App extends Component {


 render() {


 return <AppNavigator />;


 }


}



謝謝!

时间: 原作者:

74 2

原因可能是react版本與react-native版本不匹配。

嘗試將它更新為react@16.0.0-alpha.12,如下所示:


npm install react@16.0.0-alpha.12



或者將react@16.0.0-alpha.6更改為package.json,然後運行react@16.0.0-alpha.12

原作者:
...