【发布时间】:2020-10-22 23:49:05
【问题描述】:
我在我的 react native 项目中使用 eslint 和 vs 代码。
我使用 react navigation v5 创建了一个底部标签导航:
...
<Tab.Screen
name="Contacts"
component={ContactStackScreen}
options={{
tabBarLabel: 'Contacts',
tabBarColor: COLORS.DEFAULT,
tabBarIcon: ({color}) => (
<MaterialCommunityIcons name="contacts" color={color} size={26} />
),
}}
...
我收到颜色道具的 eslint 错误:
道具验证中缺少'color'
我试图修复它:
ButtomTabs.propTypes = {
color: PropTypes.string,
};
但我收到了这个错误:
propType "color" 不是必须的,但没有对应的 defaultProps 声明
【问题讨论】:
-
也许
activeTintColor和inactiveTintColor道具 Docs -
tabBarIcon 给定 {focused: boolean, color: string, size: number } 的函数返回一个 React.Node,显示在标签栏中。 // 在反应导航的文档中
标签: react-native eslint react-proptypes eslint-config-airbnb