我正在尝试在React Native应用程序中呈现一些页脚选项卡,但我不确定以下代码中的内容是否为undefined。
import React, { PropTypes } from 'react'
import { Text, TabBarIOS } from 'react-native'
FooterTabs.propTypes = {
activeFooterTab: PropTypes.string.isRequired,
onTabSelect: PropTypes.func.isRequired,
navigator: PropTypes.object.isRequired
}
export default function FooterTabs (props) {
return (
<TabBarIOS>
<TabBarIOS.item
title='home'
icon={{}}
selected={props.activeFooterTab === 'home'}
onPress={() => {props.onTabSelect('home')}} >
<Text>Home</Text>
</TabBarIOS.item>
<TabBarIOS.item
title='camera'
icon={{}}
selected={props.activeFooterTab === 'camera'}
onPress={() => {props.onTabSelect('camera')}} >
<Text>Camera</Text>
</TabBarIOS.item>
</TabBarIOS>
)
}
activeFooterTab功能
export default function activeFooterTab (state = initialState, action) {
switch (action.type) {
case SET_FOOTER_TAB :
// Returns the tab we pass in to the action creator.
return action.tab
default :
return state
}
}
onTabSelect功能
function mapDispatchToProps (dispatch) {
return {
onTabSelect: (tab) => dispatch(setFooterTab(tab))
}
}