React-native-router-flux: How do i add a right nav bar button?

Created on 19 Sep 2016  路  1Comment  路  Source: aksonov/react-native-router-flux

Version

Tell us which versions you are using:

  • react-native-router-flux v3.35.0
  • react-native v0.32.1

Expected behaviour

Add right button to nav bar, click and go to a new scene

Actual behaviour

I'm trying to add a right button in my navigation bar, but it's just rendering as a text, and i added a log for when the text is pressed but thats not happening

Steps to reproduce

  1. } type={ ActionConst.REPLACE }
    title="APP NAME" />

Most helpful comment

add following code to your COMPONENTNAME

import React from 'react';
import { TouchableOpacity, Text } from 'react-native';

class COMPONENTNAME extends React.Component {

    static renderLeftButton = (props) => {
          return (
              <TouchableOpacity onPress={() => console.log('onLeftPressed')}>
                  <Text>Left Button</Text>
              </TouchableOpacity>
          );
    }

    static renderRightButton = (props) => {
          return (
              <TouchableOpacity onPress={() => console.log('onRightPressed')}>
                  <Text>Right Button</Text>
              </TouchableOpacity>
          );
    }
}

>All comments

add following code to your COMPONENTNAME

import React from 'react';
import { TouchableOpacity, Text } from 'react-native';

class COMPONENTNAME extends React.Component {

    static renderLeftButton = (props) => {
          return (
              <TouchableOpacity onPress={() => console.log('onLeftPressed')}>
                  <Text>Left Button</Text>
              </TouchableOpacity>
          );
    }

    static renderRightButton = (props) => {
          return (
              <TouchableOpacity onPress={() => console.log('onRightPressed')}>
                  <Text>Right Button</Text>
              </TouchableOpacity>
          );
    }
}
Was this page helpful?
0 / 5 - 0 ratings