Fix NavigationView.
Reviewed By: ericvicenti Differential Revision: D3200293 fb-gh-sync-id: 3ffc7053b11f926461c45e19651d07295ca3ae72 fbshipit-source-id: 3ffc7053b11f926461c45e19651d07295ca3ae72
This commit is contained in:
parent
91a52421d4
commit
6731de7b45
|
@ -37,6 +37,7 @@ type Props = {
|
|||
};
|
||||
|
||||
type State = {
|
||||
layout: NavigationLayout,
|
||||
scenes: Array<NavigationScene>,
|
||||
};
|
||||
|
||||
|
@ -47,7 +48,6 @@ const {PropTypes} = React;
|
|||
* The most common use-case is for tabs, where no transition is needed
|
||||
*/
|
||||
class NavigationView extends React.Component<any, Props, any> {
|
||||
_layout: NavigationLayout;
|
||||
_onLayout: (event: any) => void;
|
||||
_position: NavigationAnimatedValue;
|
||||
|
||||
|
@ -63,9 +63,10 @@ class NavigationView extends React.Component<any, Props, any> {
|
|||
constructor(props: Props, context: any) {
|
||||
super(props, context);
|
||||
|
||||
this._layout = {
|
||||
const layout = {
|
||||
initWidth: 0,
|
||||
initHeight: 0,
|
||||
isMeasured: false,
|
||||
width: new Animated.Value(0),
|
||||
height: new Animated.Value(0),
|
||||
};
|
||||
|
@ -75,6 +76,7 @@ class NavigationView extends React.Component<any, Props, any> {
|
|||
this._position = new Animated.Value(navigationState.index);
|
||||
|
||||
this.state = {
|
||||
layout,
|
||||
scenes: NavigationScenesReducer([], navigationState),
|
||||
};
|
||||
}
|
||||
|
@ -116,11 +118,12 @@ class NavigationView extends React.Component<any, Props, any> {
|
|||
} = this.props;
|
||||
|
||||
const {
|
||||
layout,
|
||||
scenes,
|
||||
} = this.state;
|
||||
|
||||
const sceneProps = {
|
||||
layout: this._layout,
|
||||
layout,
|
||||
navigationState: navigationState,
|
||||
onNavigate: onNavigate,
|
||||
position: this._position,
|
||||
|
@ -150,14 +153,16 @@ class NavigationView extends React.Component<any, Props, any> {
|
|||
const {height, width} = event.nativeEvent.layout;
|
||||
|
||||
const layout = {
|
||||
...this._layout,
|
||||
...this.state.layout,
|
||||
initHeight: height,
|
||||
initWidth: width,
|
||||
isMeasured: true,
|
||||
};
|
||||
|
||||
this._layout = layout;
|
||||
layout.height.setValue(height);
|
||||
layout.width.setValue(width);
|
||||
|
||||
this.setState({ layout });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue