From ef78f60c36b959271fd57e03bb4b114dfd2aeef7 Mon Sep 17 00:00:00 2001 From: Jake Murzy Date: Thu, 7 Jul 2016 20:59:44 -0700 Subject: [PATCH] Use active scene passed in `props` by `NavigationTransitioner` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: With facebook/react-native@c57bac4, `NavigationTransitioner` passes the currently active `scene` in transition `props`. This simplifies the handling of transition changes when rendering overlay. 🍺 Closes https://github.com/facebook/react-native/pull/8298 Differential Revision: D3533447 Pulled By: ericvicenti fbshipit-source-id: df568dc5cf5d57d8948b9f0400a8d693cf5564e1 --- .../NavigationCardStack.js | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/Libraries/CustomComponents/NavigationExperimental/NavigationCardStack.js b/Libraries/CustomComponents/NavigationExperimental/NavigationCardStack.js index d04e13373ff3c0..41d2d7154e2075 100644 --- a/Libraries/CustomComponents/NavigationExperimental/NavigationCardStack.js +++ b/Libraries/CustomComponents/NavigationExperimental/NavigationCardStack.js @@ -42,8 +42,6 @@ const ReactComponentWithPureRenderMixin = require('react/lib/ReactComponentWithP const StyleSheet = require('StyleSheet'); const View = require('View'); -const emptyFunction = require('fbjs/lib/emptyFunction'); - const {PropTypes} = React; const {Directions} = NavigationCardStackPanResponder; @@ -70,7 +68,6 @@ type Props = { type DefaultProps = { direction: NavigationGestureDirection, - renderOverlay: ?NavigationSceneRenderer, }; /** @@ -102,7 +99,6 @@ class NavigationCardStack extends React.Component { static defaultProps: DefaultProps = { direction: Directions.HORIZONTAL, - renderOverlay: emptyFunction.thatReturnsNull, }; constructor(props: Props, context: any) { @@ -134,22 +130,14 @@ class NavigationCardStack extends React.Component { _render(props: NavigationTransitionProps): ReactElement { const { - navigationState, - } = props; + renderOverlay + } = this.props; let overlay = null; - const renderOverlay = this.props.renderOverlay; - if (renderOverlay) { - const route = navigationState.routes[navigationState.index]; - - const activeScene = props.scenes.find( - scene => !scene.isStale && scene.route === route ? scene : undefined - ); - overlay = renderOverlay({ ...props, - scene: activeScene + scene: props.scene, }); } @@ -157,8 +145,7 @@ class NavigationCardStack extends React.Component { scene => this._renderScene({ ...props, scene, - }), - this + }) ); return (