我在Linux机器上安装了reactnative。我想在我的练习代码中实现createBottomTabNavigator。我在里面创建了 5 个文件夹和索引.js。 导航.js :
import {createAppContainer} from 'react-navigation';
import {createBottomTabNavigator} from 'react-navigation-tabs';
import Profile from './common/pages/profile';
import Home from './common/pages/home';
import Search from './common/pages/search';
import Camera from './common/pages/camera';
import Notification from './common/pages/notification';
const Navigate=createBottomTabNavigator({
Profile:{screen:Profile},
Home:{screen:Home},
Camera:{screen:Camera},
Search:{screen:Search},
Notification:{screen:Notification}
});
export default createAppContainer(Navigate);
和主要索引.js:
import {AppRegistry} from 'react-native';
import Navigate from './navigate';
import {name as appName} from './app.json';
AppRegistry.registerComponent(appName, () => Navigate);
现在当我在Genymotion中运行时,我有错误:
- null 不是对象 ''评估 _ReanimatedModule.default.configureProps'
我的包.json:
{
"name": "myinstagram",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "16.8.6",
"react-native": "0.60.5",
"react-native-gesture-handler": "^1.4.1",
"react-native-reanimated": "^1.2.0",
"react-navigation": "^4.0.2",
"react-navigation-tabs": "^2.4.1"
},
"devDependencies": {
"@babel/core": "^7.6.0",
"@babel/runtime": "^7.6.0",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.3.0",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.56.0",
"react-test-renderer": "16.8.6"
},
"jest": {
"preset": "react-native"
}
}
检查您是否在 MainApplication 中添加了新的ReanimatedPackage(.java在getPackages下
并添加导入自:import com.swmansion.reanimated.ReanimatedPackage;
如果你使用的是 react-native 0.6,你只需要添加import com.swmansion.reanimated.ReanimatedPackage;
在您的主应用程序中.java
但是,它应该自动添加此行,因为 0.6 支持自动链接,但由于某种原因,它有时不会添加此行,因此请务必检查!
只需导入它,一切都会正常.
(在 React-Native 0.61.4 上验证(
如果您使用小于 0.6,请使用@Maksym Bezruchko 解决方案
在 android 文件夹中,android>app>src>main>java>com>app_name>MainApplication.java
文件: 添加以下导入
import com.swmansion.reanimated.ReanimatedPackage;
希望这有帮助,干杯!
就我而言,我使用的是 expo-dev-client,在安装复活的软件包并配置 babel 插件后,我不得不重建我的项目,因为它包含本机代码。