react-native-router
react-native-router copied to clipboard
Router and titleComponent
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
})
},
Any idea @t4t5?
Could you pass the initial text down in state then change the variable? It might trickle down but I'm not sure.
Thank you @MossP. I already moved to https://github.com/Kureev/react-native-navbar a week ago. Because of lack of support from author.
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).
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.
titleComponent should be set as a route property along with name and component