我正在尝试学习如何将 stacknavigator 用于我的 react-native 应用程序。但是,一旦我在页面层次结构中处于第 2 级,系统就会不断崩溃,并且我收到以下消息:
更新由 RTCView 管理的视图的属性“accessibilityLabel”时出错
我的应用程序所做的只是显示一个单词,即 Region。如果单击区域,您将看到“通用”一词。当您按“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>}
/>
);
}
}
组件/兼容性.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>;
}
}
我究竟做错了什么?我只想看到空的兼容性屏幕,并摆脱这种崩溃。