【发布时间】:2017-04-28 08:24:24
【问题描述】:
我正在尝试创建一个包含在“屏幕”文件中的全局导航栏。我对 React Native 很陌生,我遇到的问题是我也在尝试在包含的导航栏中使用 StackNavigator。通过这样做,我收到以下错误。
我正在使用以下代码。
import NavBar from "../../components/navBar";
export default class HomeView extends Component {
static navigationOptions = {
title: 'Home Screen',
headerVisible: false,
};
render() {
const { navigate } = this.props.navigation;
return (
<View style={styles.contentWrapper}>
<StatusBar hidden={true} />
<NavBar />
<View style={styles.boxTop}><Text>Test</Text></View>
<View style={styles.boxBottom}><Text>Test</Text></View>
</View>
);
}
}
在导航文件中。
import React, { Component } from 'react'
import {
StyleSheet,
Text,
View,
Image
} from 'react-native'
export default class NavBar extends Component {
render() {
const { navigate } = this.props.navigation;
return (
<View style={styles.contentWrapper}>
</View>
);
}
}
var styles = StyleSheet.create({
contentWrapper: {
flex: 1,
backgroundColor: "blue",
height: 40,
},
});
我不确定这是否是创建组件并包含 StackNavigator 的正确方法。
【问题讨论】:
标签: reactjs react-native