Permalink
Browse files

Use active scene passed in `props` by `NavigationTransitioner`

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 #8298

Differential Revision: D3533447

Pulled By: ericvicenti

fbshipit-source-id: df568dc5cf5d57d8948b9f0400a8d693cf5564e1
  • Loading branch information...
1 parent 222060b commit 46a685169e66d17c179ed7a83eea36f3988fcd9c @jmurzy jmurzy committed with Facebook Github Bot 2 Jul 8, 2016
Showing with 4 additions and 17 deletions.
  1. +4 −17 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<DefaultProps, Props, void> {
static defaultProps: DefaultProps = {
direction: Directions.HORIZONTAL,
- renderOverlay: emptyFunction.thatReturnsNull,
};
constructor(props: Props, context: any) {
@@ -134,31 +130,22 @@ class NavigationCardStack extends React.Component<DefaultProps, Props, void> {
_render(props: NavigationTransitionProps): ReactElement<any> {
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,
});
}
const scenes = props.scenes.map(
scene => this._renderScene({
...props,
scene,
- }),
- this
+ })
);
return (

0 comments on commit 46a6851

Please sign in to comment.