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 https://github.com/facebook/react-native/pull/8298

Differential Revision: D3533447

Pulled By: ericvicenti

fbshipit-source-id: df568dc5cf5d57d8948b9f0400a8d693cf5564e1
This commit is contained in:
Jake Murzy 2016-07-07 20:59:44 -07:00 committed by Facebook Github Bot 2
parent 222060b218
commit 46a685169e
1 changed files with 4 additions and 17 deletions

View File

@ -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,22 +130,14 @@ 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,
});
}
@ -157,8 +145,7 @@ class NavigationCardStack extends React.Component<DefaultProps, Props, void> {
scene => this._renderScene({
...props,
scene,
}),
this
})
);
return (