我根本找不到让反应导航工作的方法。我从互联网上复制了工作示例,但它们似乎也不起作用。有人可以告诉我我做错了什么吗?
我在用着
节点:8.9.4
反应:16.3.0-alpha.1
反应本机:0.54.0
反应导航:^1.4.0
//index.js
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import {
TabNavigator,
StackNavigator
} from 'react-navigation';
import Home from './first';
import Homes from './second';
export default class demoApp extends Component {
render() {
return (
<SimpleNavigation/>
);
}
}
export const SimpleNavigation = StackNavigator({
Home: {
screen: Home,
header: { visible: false },
navigationOptions: {
title: 'Home',
header: null
},
},
Homes: {
screen: Homes,
navigationOptions: {
title: 'second'
},
},
},{});
这是第一个选项卡
//first.js
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Image,
TextInput,
Button,
TouchableHighlight
} from 'react-native';
export default class Home extends Component {
constructor(props){
super(props);
this.state = {zipCode: ''}
}
navigate = (zipCode) => {
this.props.navigation.navigate('Search', zipCode);
}
render() {
return (
<View>
<View>
<Text>An application to do things</Text>
<TextInput
placeholder='Enter a Zip Code'
onChangeText={(zipCode) => this.setState({zipCode})}
>
</TextInput>
</View>
<View>
<TouchableHighlight onPress={() => this.navigate(this.state.zipCode)}>
<Text>
Search
</Text>
</TouchableHighlight>
</View>
</View>
);
}
}
我似乎根本无法让它运行。我也尝试遵循许多其他教程。但它们都不起作用。我究竟做错了什么?