Skip to content

Commit

Permalink
Use active scene passed in props by NavigationTransitioner
Browse files Browse the repository at this point in the history
Summary:
With 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
jmurzy authored and Facebook Github Bot 2 committed Jul 8, 2016
1 parent 222060b commit 46a6851
Showing 1 changed file with 4 additions and 17 deletions.
Expand Up @@ -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;

Expand All @@ -70,7 +68,6 @@ type Props = {

type DefaultProps = {
direction: NavigationGestureDirection,
renderOverlay: ?NavigationSceneRenderer,
};

/**
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit 46a6851

Please sign in to comment.