2016-08-03 7 views
0

私はreact-nativeプロジェクトで作業しており、最近0.26から0.30にアップグレードしました。 ナビゲーション実験は、特に名前付け(NavigationRouteNavigationState、...)と、onNavigateBackとなるNavigationCardStackの方法onNavigateの変更にかなりの変更を受けました。NavigationExperimentalプロパティ 'onNavigateBack`が見つかりません

私はフロー0.27.0を使用して自分のコードをチェックしています。

のエラーからのエラーです。

app/containers/MyContainer.js:99 
99:   <NavigationCardStack 
       ^props of React element `NavigationCardStack` 
67: type Props = NavigationSceneRendererProps & { 
               ^property `onNavigateBack`. Property not found in. See: node_modules/react-native/Libraries/CustomComponents/NavigationExperimental/NavigationHeader.js:67 
113:    {...props} 
         ^^^^^ spread of identifier `props` 

app/containers/MyContainer.js:112 
112:   <NavigationHeader 
       ^React element `NavigationHeader` 
67: type Props = NavigationSceneRendererProps & { 
               ^property `onNavigateBack`. Property not found in. See: node_modules/react-native/Libraries/CustomComponents/NavigationExperimental/NavigationHeader.js:67 
113:    {...props} 
         ^^^^^ spread of identifier `props` 

ここにエラーが発生したコードを示します。 this.props.onNavigateBackは、reduxのconnectメソッドからその値を取得します。

class MyContainer extends Component { 
    props: Props; 

    render() { 
     return (
      <NavigationCardStack 
       navigationState={this.props.navigationState} 
       onNavigateBack={this.props.onNavigateBack} 
       renderOverlay={props => this._renderNavigationHeader(props)} 
       renderScene={scene => (<View />)} 
       style={styles.container} 
      /> 
     ) 
    } 

    _renderNavigationHeader(props) { 
     return (
      <NavigationHeader 
       {...props} 
       style={styles.header} 
       textStyle={styles.title} 
       renderLeftComponent={props => (<View />)} 
       renderRightComponent={props => (<View />)} 
       renderTitleComponent={props => (<View />)} 
      /> 
     ) 
    } 
} 

私は私が宣言Propsタイプが() => voidとしてonNavigateBack含まれています、できるだけコードは限り短く作ってみました。

答えて

0

わかりました。私はrenderOverlayが与えられた方法にonNavigateBackを渡したと仮定しましたが、そうではないようです。それについてはわかっていないが、私はそれがまだonNavigateだった前のケースだと思う。

したがって、修正オペレータでpropsを参照する代わりに、this.props.onNavigateBackを直接参照するように修正されています。

_renderNavigationHeader(props) { 
    return (
     <NavigationHeader 
      {…props} 
      onNavigateBack={this.props.onNavigateBack} 
      style={styles.header} 
      textStyle={styles.title} 
      renderLeftComponent={props => (<View />)} 
      renderRightComponent={props => (<View />)} 
      renderTitleComponent={props => (<View />)} 
     /> 
    ) 
} 
関連する問題