2016-05-31 10 views
0

RN Navigatorの上に構築されたhttps://github.com/exponentjs/ex-navigatorを使用しています。これは、すべてのシーンに対して手動で手書きしなくても、すべてのシーンに対して小道具を渡す/設定する方法はありますか?私が50のシーンを持っていて、いくつかの不動産をすべてのシーンに渡したいのですか?ナビゲータ、現在のシーンに小道具を渡しますか?

これは、トップレベルのコンポーネント(上のナビゲータ)です。これは、ナビゲータに小道具を渡すことになっています。ナビゲータは、その小道具を現在表示されているシーンに渡す必要があります。それは可能ですか?

ありがとうございました。

答えて

2

はい、可能です。それらの小道具をレンダリングされたシーンに渡すことができます。あなたは...このような何かを試みることができる

renderScene={(route, navigator) => { 
 
      // in my implementation, I pass the component as a prop of route. 
 
      let RoutedComponent = route.component 
 

 
      // you can pass props into the route itself, or pass down arbitrary props from the parent component 
 
      return (
 
       <RoutedComponent navigator={navigator} {this.props.somePropFromParent} {...route.props}/> 
 
      ) 
 
}}

関連する問題