Eric Eric - 3 months ago 260
iOS Question

how to make right button in navigation bar using react-native-router-flux?

I am tring to make right button on navigation bar using react-native-router-flux.

My code is

import React from 'React';
import { TouchableHighlight } from 'react-native';
import { Scene, Router, Actions } from 'react-native-router-flux';
...
const filterIcon = () => (
<TouchableHighlight onPress={()=>} style={{...}}>
<Icon name="filter" size={30}/>
</TouchableHighlight>
);
const MainRounter=()=>(
<Router>
<Scene
key="main"
component={mainPage}
initial={true}
renderRightButton={()=>filterIcon}
/>
</Router>
);


But I can't show right button on navigation bar.
How can I make it?

Answer

You can use the onRight, rightTitle or rightButtonImage to add the right button to the navBar.

const MainRounter = return (
    <Router>
        <Scene
            key="main"
            component={mainPage}
            initial={true}
            onRight={ ()=> whatever you want to do }
            rightButtonImage={require('path/to/your/icon')}
        />
    </Router>
);

Let me know if it worked :)

Comments