我在学习如何使用stacknavigator作为我的react-native应用程序。但该系统不断崩溃一旦我在页面层次结构2级和我得到的消息:StackNavigator不能嵌套多个级别?
错误,同时更新属性“accessibilityLabel”的视图通过管理:RTCView
我的全部应用程序会提供一个说“地区”的字词。如果你点击地区,你会看到一般的单词。当你按下General一词时,你应该看到一个空的屏幕,但是我得到了上面提到的错误和崩溃。
下面的代码到我的简单的项目:
index.android.js
import React, { Component } from 'react';
import App from './components/Home';
import {
AppRegistry,
View
} from 'react-native';
export default class myapp extends Component {
render() {
return (
<App />
);
}
}
AppRegistry.registerComponent('myapp',() => myapp);
组件/ Home.js
import React, { Component } from 'react';
import {StackNavigator} from 'react-navigation';
import Regions from './Regions';
import Compatibility from './Compatibility';
import {
AppRegistry,
StyleSheet,
Text,
View,
Linking
} from 'react-native';
class Home extends Component {
static navigationOptions = {
title: 'Login',
headerStyle: {
backgroundColor:'#000000'
},
headerTitleStyle: {
color:'#fff'
}
};
render(){
const {navigate} = this.props.navigation;
return (
<View style={styles.container}>
<Text style={styles.instructions} onPress={()=>navigate('Regions',{realm:'blah'})}>
Regions
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
const myscreens = StackNavigator({
Home: {screen: Home},
Regions:{screen:Regions},
Compatibility:{screen:Compatibility}
});
export default myscreens;
组件/ Regions.js
import React, { Component } from 'react';
import {StackNavigator} from 'react-navigation';
import {
Text,
View,
FlatList
} from 'react-native';
export default class Regions extends Component {
static navigationOptions = {
title: 'Pick Region',
headerStyle: {
backgroundColor:'#F00'
},
headerTitleStyle: {
color:'#fff'
},
headerTruncatedBackTitle:{
color:'#fff'
},
headerBackTitle:{
color:'#fff'
},
headerBackTitleStyle:{
color:'#fff'
},
headerTruncatedBackTitle:{
color:'#fff'
}
};
constructor(props)
{
super(props);
}
render() {
const {navigate} = this.props.navigation;
let data = [
{regionName:'General',numOfDimensions:2}
];
return (
<FlatList
data={data}
keyExtractor={(item, index) => index}
renderItem={({item}) => <Text onPress={()=>navigate('Compatibility',{item:item})}>{item.regionName}</Text>}
/>
);
}
}
组件/Compatibility.js
import React, { Component } from 'react';
import {
Text,
View,
FlatList
} from 'react-native';
export default class Compatibility extends Component {
static navigationOptions = {
title: 'Pick Region',
headerStyle: {
backgroundColor:'#F00'
},
headerTitleStyle: {
color:'#fff'
},
headerTruncatedBackTitle:{
color:'#fff'
},
headerBackTitle:{
color:'#fff'
},
headerBackTitleStyle:{
color:'#fff'
},
headerTruncatedBackTitle:{
color:'#fff'
}
};
constructor(props)
{
super(props);
}
render() {
console.log('Compatibility');
return <View></View>;
}
}
我在做什么错?我只想看到空的兼容性屏幕,并摆脱这种崩溃。