React Native +图标:警告:失败的道具类型:无效的props.style键tintColor提供给ForwardRef(Text)

时间:2019-07-12 20:13:33

标签: javascript reactjs react-native react-navigation react-native-ui-kitten

在带有底部导航选项卡的基本React-native应用程序中,

<BottomNavigationTab title='Baz' icon={() => <Icon name='line-chart' size={20} color='#000' />} />

显示错误消息

  

警告:道具类型失败:提供给`ForwardRef(Text)`的props.style键'tintColor'无效。

但是,如果我们要删除Icon元素,那么

<BottomNavigationTab title='Baz />

工作正常。

问题:是什么原因造成的,我们该如何解决?

使用

完整代码

import React from 'react';
import { createBottomTabNavigator, createStackNavigator, createSwitchNavigator, createAppContainer } from 'react-navigation';
import { BottomNavigation, BottomNavigationTab, BottomNavigationProps, Avatar } from 'react-native-ui-kitten';
import Icon from 'react-native-vector-icons/FontAwesome';

import ProfitScreen from '../screens/Profit';

class BottomNavigationShowcase extends React.Component {
    state = {
        selectedIndex: 0,
    };

    onTabSelect = (selectedIndex) => {
        this.setState({ selectedIndex });
    };

    render () {
        return (
            <BottomNavigation
                selectedIndex={this.state.selectedIndex}
                onSelect={this.onTabSelect}
            >
                <BottomNavigationTab title='Baz' icon={() => <Icon name='line-chart' size={20} color='#000' />} />
            </BottomNavigation>
        );
    }
}

const FooStack = createStackNavigator({
    Bar: BarScreen
})

const TabNavigator = createBottomTabNavigator(
    {
        Foo: FooStack,
    }, {
        initialRouteName: 'Foo',
        tabBarComponent: BottomNavigationShowcase
    }
)

const RootNavigator = createSwitchNavigator({
    Main: TabNavigator,
}, {
    initialRoute: "Main"
})

const AppContainer = createAppContainer(RootNavigator);

export default AppContainer 

1 个答案:

答案 0 :(得分:1)

万一有人遇到此问题-here is an answer on Github