Search code examples
react-nativereact-native-router-flux

How to add icon on right button using react native router flux


I want to add a react-native-vector-icon in place of the right button in the header using react native router flux

Here is my code :

<Scene
    onRight={() => Actions.inbox()} 
    rightTitle='Inbox' 
    key='home'
    component={Home} 
    title='Home'
    icon={HomeIcon}
    initial
/> 

How to add react-native-vector-icon in this?


Solution

  • I got it, I used renderRightButton for solving it.

    here is the example:

    const InboxIcon = () => {
        return (
            <View style={{ marginRight: 10 }} >
                <TouchableOpacity onPress={() => Actions.inbox()} >
                    <Icon
                        name='comment'
                        type='font-awesome'
                        size={30}
                    />
                </TouchableOpacity>
            </View>
        );
    };
    

    And in scene I render it. Like this,

    <Scene
            renderRightButton={InboxIcon}  
            key='home'
            component={Home} 
            title='Home'
            icon={HomeIcon}
            initial
        />