-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add augmentScene and augmentNavigationBar methods #2
Conversation
Also deleted duplicate |
I think this is the problem that I get here #3 |
<Navigator.NavigationBar | ||
routeMapper={this._routeRenderer.navigationBarRouteMapper} | ||
style={[ExNavigatorStyles.bar, this.props.navigationBarStyle]} | ||
/> | ||
); | ||
|
||
return this.augmentNavigationBar(navigationBar); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this again I think a prop would be preferable:
let navigationBar = this.props.renderNavigationBar({
routeMapper: this._routeRenderer.navigationBarRouteMapper,
style: [ExNavigatorStyles.bar, this.props.navigationBarStyle],
});
And use defaultProps
to render a basic Navigator.NavigationBar
by default.
For the inheritance case I think we could override defaultProps
:
class CustomNavigator extends ExNavigator {
static defaultProps = {
...ExNavigator.defaultProps,
renderNavigationBar: props => <CustomNavigationBar {...props} />,
};
}
@jadsonlourenco this fixes the problem in #3 so you can use this branch for now. I'm going to work on some of the other things I changed in this pull so I won't merge it quite yet. |
} | ||
|
||
let scene = this._routeRenderer.renderScene(route, this); | ||
scene = this.augmentScene(scene, route); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I'm thinking this actually could be a prop (this.props.augmentScene
). Then the owner of the ExNavigator (instead of its subclass) could write:
render() {
return <ExNavigator augmentScene={this._augmentScene} />;
}
@autobind
_augmentScene(scene, route) {
...
}
452dd4d
to
96db52d
Compare
Thanks Jesse! |
Add augmentScene and augmentNavigationBar methods
Call
_subscribeToFocusEvents
withnavigator
instead ofthis
. Otherwisenavigator.navigationContext
crashes.Add
augmentScene
andaugmentNavigationBar
which can be overridden to add custom components to every scene/navigation bar.