如何修复提供给“图标”的无效道具“颜色”?

时间:2019-05-27 08:20:39

标签: react-native

我正在使用“ react-native-vector-icons”中的图标设置一个新组件,并且出现黄色警告。

这是图标的新功能

Dashboard: {
        screen: DashboardStack,
        navigationOptions: {
            title: 'HOME',
            tabBarOnPress: ({ navigation, defaultHandler }) => handleTabPress(navigation, defaultHandler),
            tabBarIcon: ({ focused, tintColor }) => {
                // HERE IS THE PROBLEM //
            return <SSIcon name={'home'} size={20} color={focused ? GStyle.GREEN : Color(GStyle.BLACK).alpha(.45)} />

            },

        }
    },

我希望没有黄色警告

3 个答案:

答案 0 :(得分:0)

您可以尝试使用此代码

 <SSIcon name={'home'} size={20} color={focused ? "green" : "black"} />

答案 1 :(得分:0)

您是否尝试过分色?

const stackNav = createStackNavigator ({
Dashboard: {
        screen: DashboardStack,
        navigationOptions: {
            title: 'HOME',
            tabBarOnPress: ({ navigation, defaultHandler }) => handleTabPress(navigation, defaultHandler),
            tabBarIcon: ({ focused, tintColor }) => <SSIcon name={'home'} size={20} color={tintColor} />


        }

}}, {
  tabBarOptions: { 
     activeTintColor:GStyle.GREEN,
     inactiveTintColor: Color(GStyle.BLACK).alpha(.45)
})

答案 2 :(得分:-1)

  

在应用程序的根index.js中添加以下行:

console.disableYellowBox = true;