你可以创建一个额外的
Functional Component
添加
PropTypes
并在主要部件中使用。例如:
...
import PropTypes from 'prop-types';
...
const QuestionsTabBarIcon = ({ tintColor }) => (
<Icon name="question-circle" type="font-awesome" size={20} color={tintColor} />
);
QuestionsTabBarIcon.propTypes = {
tintColor: PropTypes.string.isRequired,
};
...
const ContentNavigator = TabNavigator(
{
Profile: { screen: ProfileStack },
History: { screen: HistoryStack },
Questions: {
screen: QuestionsStack,
navigationOptions: {
tabBarIcon: QuestionsTabBarIcon
},
},
Notifications: { screen: NotificationsStack },
},
{
initialRouteName: 'Profile',
swipeEnabled: true,
tabBarOptions: {
activeTintColor: COLOR_PRIMARY,
},
backBehavior: 'none',
}
);
...