From 6731de7b45d0bbafe16351f2fa808b35e33f7c3b Mon Sep 17 00:00:00 2001 From: Hedger Wang Date: Tue, 19 Apr 2016 19:55:31 -0700 Subject: [PATCH] Fix NavigationView. Reviewed By: ericvicenti Differential Revision: D3200293 fb-gh-sync-id: 3ffc7053b11f926461c45e19651d07295ca3ae72 fbshipit-source-id: 3ffc7053b11f926461c45e19651d07295ca3ae72 --- .../NavigationExperimental/NavigationView.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Libraries/NavigationExperimental/NavigationView.js b/Libraries/NavigationExperimental/NavigationView.js index 91fea56cf..157e1d36d 100644 --- a/Libraries/NavigationExperimental/NavigationView.js +++ b/Libraries/NavigationExperimental/NavigationView.js @@ -37,6 +37,7 @@ type Props = { }; type State = { + layout: NavigationLayout, scenes: Array, }; @@ -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 { - _layout: NavigationLayout; _onLayout: (event: any) => void; _position: NavigationAnimatedValue; @@ -63,9 +63,10 @@ class NavigationView extends React.Component { 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 { this._position = new Animated.Value(navigationState.index); this.state = { + layout, scenes: NavigationScenesReducer([], navigationState), }; } @@ -116,11 +118,12 @@ class NavigationView extends React.Component { } = 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 { 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 }); } }