Skip to content

Commit 5661e79

Browse files
Merge pull request #20 from davodesign84/titleProps
added setTitleProps to send props to custom components
2 parents 0ced1e2 + 7e0aaf8 commit 5661e79

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

components/NavBarContainer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ var NavBarContainer = React.createClass({
6868
goForward={this.goForward}
6969
leftProps={this.props.leftProps}
7070
rightProps={this.props.rightProps}
71+
titleProps={this.props.titleProps}
7172
customAction={this.customAction}
7273
/>
7374
</View> )

components/NavBarContent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ var NavBarContent = React.createClass({
104104

105105
if (this.props.route.titleComponent) {
106106
var TitleComponent = this.props.route.titleComponent;
107-
titleContent = <TitleComponent />;
107+
titleContent = <TitleComponent {...this.props.titleProps} />;
108108
} else {
109109
titleContent = (
110110
<Text style={[styles.navbarText, this.props.titleStyle]} numberOfLines={1}>

index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ var Router = React.createClass({
5959
this.setState({ leftProps: props });
6060
},
6161

62+
setTitleProps: function(props) {
63+
this.setState({ titleProps: props });
64+
},
65+
6266
customAction: function(opts) {
6367
this.props.customAction(opts);
6468
},
@@ -91,6 +95,10 @@ var Router = React.createClass({
9195
this.setState({ leftProps: props });
9296
}.bind(this);
9397

98+
var setTitleProps = function(props) {
99+
this.setState({ titleProps: props });
100+
}.bind(this);
101+
94102
var customAction = function(opts) {
95103
this.customAction(opts);
96104
}.bind(this);
@@ -151,6 +159,7 @@ var Router = React.createClass({
151159
reset={goToFirstRoute}
152160
setRightProps={setRightProps}
153161
setLeftProps={setLeftProps}
162+
setTitleProps={setTitleProps}
154163
customAction={customAction}
155164
{...route.passProps}
156165
/>
@@ -189,6 +198,7 @@ var Router = React.createClass({
189198
toBack={this.onBack}
190199
leftProps={this.state.leftProps}
191200
rightProps={this.state.rightProps}
201+
titleProps={this.state.titleProps}
192202
customAction={this.customAction}
193203
/>
194204
}

0 commit comments

Comments
 (0)