import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View, Image } from 'react-native'; import TabNavigator from 'react-native-tab-navigator'; export default class imooc_old extends Component { constructor(props) { super(props) this.state = { selectedTab: 'home', } } render() { return ( <View style={styles.container}> <TabNavigator> <TabNavigator.Item selected={this.state.selectedTab === 'home'} title="Home" renderIcon={() => <Image source={require('./res/images/ic_polular.png')} />} renderSelectedIcon={() => <Image source={require('./res/images/ic_polular.png')} />} badgeText="1" onPress={() => this.setState({ selectedTab: 'home' })}> <View style={styles.page1}></View> </TabNavigator.Item> <TabNavigator.Item selected={this.state.selectedTab === 'profile'} title="Profile" renderIcon={() => <Image source={require('./res/images/ic_polular.png')} />} renderSelectedIcon={() => <Image source={require('./res/images/ic_polular.png')} />} onPress={() => this.setState({ selectedTab: 'profile' })}> <View style={styles.page2}></View> </TabNavigator.Item> </TabNavigator> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, page1:{ backgroundColor:'red' }, page2:{ backgroundColor:'yellow' } }); AppRegistry.registerComponent('imooc_old', () => imooc_old);