React native `不同屏幕之间的反应导航,得到500个错误
我按照文档进行操作,但仍然会遇到可怕的错误 我用代码添加了下面的屏幕,请告知我缺少什么。 app.js页面加载到index.js中React native `不同屏幕之间的反应导航,得到500个错误,react-native,react-navigation,React Native,React Navigation,我按照文档进行操作,但仍然会遇到可怕的错误 我用代码添加了下面的屏幕,请告知我缺少什么。 app.js页面加载到index.js中 反应-native@.55 反应-navigation@2.5.2 App.js import React, { Component } from 'react'; import AppNavigator from './components/app.navigator'; import { StyleProvider } from 'native-base';
反应-native@.55
反应-navigation@2.5.2
App.js
import React, { Component } from 'react';
import AppNavigator from './components/app.navigator';
import { StyleProvider } from 'native-base';
import getTheme from './native-base-theme/components';
import CustomTheme from './native-base-theme/variables/custom.material';
export default class App extends Component {
render() {
return (
<StyleProvider style={getTheme(CustomTheme)}>
<AppNavigator/>
</StyleProvider>
);
}
}
import React,{Component}来自'React';
从“./components/app.navigator”导入AppNavigator;
从“本机基”导入{StyleProvider};
从“./native base-theme/components”导入getTheme;
从“./native base-theme/variables/custom.material”导入CustomTheme;
导出默认类应用程序扩展组件{
render(){
返回(
);
}
}
app.navigator.js
import React from 'react';
import { StackNavigator, TabNavigator, TabBarBottom } from 'react-navigation'; // Version can be specified in package.json
import HomeScreen from './components/HomeScreen';
import SettingsScreen from './components/SettingsScreen';
import DetailsScreen from './components/DetailsScreen';
const HomeStack = StackNavigator({
Home: { screen: HomeScreen },
Details: { screen: DetailsScreen },
});
const SettingsStack = StackNavigator({
Settings: { screen: SettingsScreen },
Details: { screen: DetailsScreen },
});
export default TabNavigator(
{
Home: { screen: HomeStack },
Settings: { screen: SettingsStack },
},
{
navigationOptions: ({ navigation }) => ({
tabBarIcon: ({ focused, tintColor }) => {
const { routeName } = navigation.state;
let iconName;
if (routeName === 'Home') {
iconName = `ios-information-circle${focused ? '' : '-outline'}`;
} else if (routeName === 'Settings') {
iconName = `ios-options${focused ? '' : '-outline'}`;
}
// You can return any component that you like here! We usually use an
// icon component from react-native-vector-icons
return <Icon name={iconName} size={25} color={tintColor} />;
},
}),
tabBarComponent: TabBarBottom,
tabBarPosition: 'bottom',
tabBarOptions: {
activeTintColor: 'tomato',
inactiveTintColor: 'gray',
},
animationEnabled: false,
swipeEnabled: false,
}
);
从“React”导入React;
从“react navigation”导入{StackNavigator,TabNavigator,TabBarBottom};//可以在package.json中指定版本
从“./组件/主屏幕”导入主屏幕;
从“/components/SettingsScreen”导入设置屏幕;
从“./components/DetailsScreen”导入DetailsScreen;
const HomeStack=StackNavigator({
主屏幕:{屏幕:主屏幕},
详细信息:{screen:DetailsScreen},
});
const SettingsStack=StackNavigator({
设置:{屏幕:设置屏幕},
详细信息:{screen:DetailsScreen},
});
导出默认选项卡导航器(
{
主页:{screen:HomeStack},
设置:{screen:SettingsStack},
},
{
导航选项:({navigation})=>({
tabBarIcon:({focused,tintColor})=>{
const{routeName}=navigation.state;
让我来;
如果(routeName==='Home'){
iconName=`ios信息圈${聚焦?''''-outline'}`;
}else if(routeName==='Settings'){
iconName=`ios选项${focused?''''-outline'}`;
}
//您可以返回任何您喜欢的组件!我们通常使用
//来自本机向量图标的图标组件
返回;
},
}),
tabBarComponent:TabBarBottom,
tabBarPosition:'底部',
选项卡选项:{
activeTintColor:‘番茄’,
颜色:“灰色”,
},
animationEnabled:错误,
swipeabled:false,
}
);
屏幕页面除了名称之外都很相似
设置Screen.js、detailScreen.js、homeScreen.js
import React, { Component } from 'react';
import { View, Text, Button } from 'react-native';
export default class SettingsScreen extends Component {
render() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Settings!</Text>
<Button
title="Go to Home"
onPress={() => this.props.navigation.navigate('Home')}
/>
<Button
title="Go to Details"
onPress={() => this.props.navigation.navigate('Details')}
/>
</View>
);
}
}
import React,{Component}来自'React';
从“react native”导入{视图、文本、按钮};
导出默认类设置屏幕扩展组件{
render(){
返回(
设置!
this.props.navigation.navigate('Home')}
/>
this.props.navigation.navigate('Details')}
/>
);
}
}
您从哪里得到错误?在android上,“开发服务器返回响应错误代码:500”您好,我得到了相同的错误。您得到了解决方案吗?