react-native-router icon indicating copy to clipboard operation
react-native-router copied to clipboard

Router and titleComponent

Open JonasJonny opened this issue 10 years ago • 6 comments

Hello @t4t5. Is there a way how to set "titleComponent" on router? I need to change title/name ('Home') for search component (SearchBar) without any "click/press" action.

Thank you very much.

//twitter-example/index.js
var firstRoute = {
  name: 'Home',
  component: HomePage,
  leftCorner: AddPeople
};

var TwitterApp = React.createClass({
  render() {
    return (
      <Router 
        firstRoute={firstRoute} 
        headerStyle={styles.header}
        backButtonComponent={BackButton}
        rightCorner={SearchAndCompose}
      />
    )
  }
});

//twitter-example/components/icons/SearchAndCompose.js
var SearchBar = React.createClass({
  render() {
    return (
      <TextInput style={styles.input} placeholder="Search Twitter" />
    )
  }
});


var SearchAndCompose = React.createClass({

  goToSearch: function() {
    this.props.toRoute({
      name: "Search",
      component: SearchPage,
      rightCorner: ComposeIcon,
      titleComponent: SearchBar
    })
  },

JonasJonny avatar May 03 '15 17:05 JonasJonny

Any idea @t4t5?

JonasJonny avatar May 05 '15 14:05 JonasJonny

Could you pass the initial text down in state then change the variable? It might trickle down but I'm not sure.

MossP avatar May 15 '15 12:05 MossP

Thank you @MossP. I already moved to https://github.com/Kureev/react-native-navbar a week ago. Because of lack of support from author.

JonasJonny avatar May 15 '15 13:05 JonasJonny

No probs @JonasJonny, I had been using that, but got stuck with it. How are you finding it? Do you have a sample app that you could post using it? (I'm new to React).

MossP avatar May 15 '15 14:05 MossP

Hey @JonasJonny. Sorry for the late reply, I have been very busy this last month. :-)

I'm not sure I understand your use case. Maybe the other library solved your problems and in that case you should ofc stick with it, but if not, would you mind clarifying what sort of behaviour you're looking for in your app?

Cheers.

t4t5 avatar Jun 10 '15 10:06 t4t5

titleComponent should be set as a route property along with name and component

sconxu avatar Sep 10 '15 14:09 sconxu