mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-01 21:12:19 +08:00
Refactor <NavigationHeader /> API.
Summary:- All the public sub component renderers should implement the interface NavigationSceneRenderer, which will help to reuse renderer or replace renders for different composition. - Perf improvement. <NavigationHeader /> is rendering way more sub component than necessary, we shall fix that. - No UI or behavior change. Reviewed By: ericvicenti Differential Revision: D3091442 fb-gh-sync-id: fba5f7ce74597fa6036b5b216c02b06052801983 shipit-source-id: fba5f7ce74597fa6036b5b216c02b06052801983
This commit is contained in:
committed by
Facebook Github Bot 9
parent
433fb336af
commit
62e80a600e
@@ -58,10 +58,11 @@ const NavigationBasicReducer = NavigationReducer.StackReducer({
|
||||
|
||||
class NavigationAnimatedExample extends React.Component {
|
||||
componentWillMount() {
|
||||
this._renderNavigation = this._renderNavigation.bind(this);
|
||||
this._renderCard = this._renderCard.bind(this);
|
||||
this._renderScene = this._renderScene.bind(this);
|
||||
this._renderHeader = this._renderHeader.bind(this);
|
||||
this._renderNavigation = this._renderNavigation.bind(this);
|
||||
this._renderScene = this._renderScene.bind(this);
|
||||
this._renderTitleComponent = this._renderTitleComponent.bind(this);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
@@ -99,14 +100,20 @@ class NavigationAnimatedExample extends React.Component {
|
||||
_renderHeader(/*NavigationSceneRendererProps*/ props) {
|
||||
return (
|
||||
<NavigationHeader
|
||||
navigationProps={props}
|
||||
renderTitleComponent={(navigationProps, scene) => {
|
||||
return <NavigationHeader.Title>{scene.navigationState.key}</NavigationHeader.Title>;
|
||||
}}
|
||||
{...props}
|
||||
renderTitleComponent={this._renderTitleComponent}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
_renderTitleComponent(/*NavigationSceneRendererProps*/ props) {
|
||||
return (
|
||||
<NavigationHeader.Title>
|
||||
{props.scene.navigationState.key}
|
||||
</NavigationHeader.Title>
|
||||
);
|
||||
}
|
||||
|
||||
_renderCard(/*NavigationSceneRendererProps*/ props) {
|
||||
return (
|
||||
<NavigationCard
|
||||
|
||||
Reference in New Issue
Block a user