使用最新的react本机版本时,createBottomTabNavigator和无法识别的字体系列出现问题



错误图像模拟器

我是一个反应原生开发的新手,实际上我正在观看一段克隆Instagram应用程序的教程视频。但这家伙似乎使用了一个旧的react原生版本,这给我带来了很多错误。我已经尝试了所有的解决方案和在线,但似乎都不起作用。

图标优先:

我尝试过使用npx-react本机链接,但手动配置也不起作用,但没有一个对我起作用,这让我很难过。

对于导航:

我甚至试过官方网站上的样品,但实际上对我不起作用。

如果我需要从头开始重新修改代码,我不会介意,因为我已经无数次删除并重新启动了整个项目。

期待中的谢谢。。。

这是我的App.js

/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React from 'react';
import { StyleSheet, Text, View } from 'react-native'
import {createAppContainer} from 'react-navigation';
import {createStackNavigator} from 'react-navigation-stack';
import MainScreen from './Components/MainScreen'
const MainNavigator = createStackNavigator({
Main: {screen: MainScreen},
});
const App = createAppContainer(MainNavigator);
export default App;

这是我的MainScreen.js

import React, { Component } from 'react'
import { Text, StyleSheet, View } from 'react-native'
import { createAppContainer } from 'react-navigation';
import { createBottomTabNavigator } from 'react-navigation-tabs';
import AddMediaTab from './AppTabNavigator/AddMediaTab'
import HomeTab from './AppTabNavigator/HomeTab'
import LikesTab from './AppTabNavigator/LikesTab'
import ProfileTab from './AppTabNavigator/ProfileTab'
import SearchTab from './AppTabNavigator/SearchTab'
import { Icon } from 'native-base'
//import Icon from 'react-native-vector-icons/Ionicons';
class MainScreen extends Component {
static navigationOptions = {
headerLeft: <Icon name="ios-camera-outline" style={{ paddingLeft: 10 }} />,
title: "Instagram",
headerRight:<Icon style={{ paddingRight:10 }} name="ios-send-outline" />
}
render() {
return (
<AppTabNavigator />
);
}
}
const AppTabNavigator = createBottomTabNavigator({
HomeTab: {
screen: HomeTab
},
SearchTab: {
screen: SearchTab
},
AddMediaTab: {
screen: AddMediaTab
},
LikesTab: {
screen: LikesTab
},
ProfileTab: {
screen: ProfileTab
}
})
export default MainScreen;
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
}
});

这是我的包.json

{
"name": "InstagramClone",
"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": {
"native-base": "^2.13.8",
"react": "16.9.0",
"react-native": "0.61.4",
"react-native-gesture-handler": "^1.5.0",
"react-native-reanimated": "^1.4.0",
"react-native-screens": "^2.0.0-alpha.11",
"react-native-vector-icons": "^6.6.0",
"react-navigation": "^4.0.10",
"react-navigation-stack": "^1.10.3",
"react-navigation-tabs": "^2.5.6"
},
"devDependencies": {
"@babel/core": "^7.6.2",
"@babel/runtime": "^7.6.2",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.5.1",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.56.0",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}

本机模块未链接时会发生错误。使用最新的React Native,您根本不应该运行react-native link。这是自动的。

安装依赖项后,请确保安装pod:

cd ios && pod install

然后重建你的应用程序">

react-native run-ios // or run-android 

相关内容

  • 没有找到相关文章

最新更新