`react-native-vector-icons`和`react-navigation`一起用就报错,求助



  • react-native-vector-iconsreact-navigation一起用就报错

    Possible Unhandled Promise Rejection (id: 0):
    TypeError: Cannot read property 'remove' of undefined
    TypeError: Cannot read property 'remove' of undefined
        at TabBar.componentWillUnmount (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:57598:29)
        at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:21938:29
        at measureLifeCyclePerf (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:21841:16)
        at ReactCompositeComponentWrapper.unmountComponent (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:21937:20)
        at Object.unmountComponent (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:21569:220)
        at ReactCompositeComponentWrapper.unmountComponent (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:21940:59)
        at Object.unmountComponent (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:21569:220)
        at Object.unmountChildren (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:23017:35)
        at Constructor.unmountChildren (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:23205:32)
        at Constructor.unmountComponent (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:23234:60)
    

    icon在其他地方可以使用,完全按照官方的来的,但是用在TabNavigator里面

    const FirmTab = TabNavigator(
        {
            firmlist: {
                screen: FirmList,
                navigationOptions: {
                    tabBarIcon: ({tintColor, focused}) => (
                        <Icon
                                name='eye'
                                size={26}
                                style={{color: tintColor}}
                        />
                )}
            },
    
            myfirm: {
                screen: MyFirms,
                navigationOptions: {
                    tabBarIcon: ({tintColor, focused}) => (
                        <Icon
                                name='eye'
                                size={26}
                                style={{color: tintColor}}
                        />
                )}
            },
            
        }, {
            initialRouteName: 'firmlist',
            mode: 'card',
            swipeEnabled: false,
            animationEnabled: false,
            tabBarOptions: {
                showIcon: true,
            }
        }
    )
    

    就不行

    求助



  • 解决了。。乌龙事件
    引用

    import Icon from 'react-native-vector-icons/FontAwesome';
    

    的地方,必须要引用

    import React, {Component} from 'react';
    

    散了吧。


登录后回复