用我的index.ios.js反應母語抽屜(https://github.com/root-two/react-native-drawer),我有以下設置,並試圖通過「導航」參考爲內容的< DrawerPanel/<抽屜/>的>。我console.log(this.props.navigator)在< DrawerPanel />但是當我試圖做類似於this.props.navigator.replace()的時候傳入一個錯誤的導航器引用在< DrawerPanel />如何將導航器引用傳遞給React Native <Drawer/>?
如何傳遞正確的導航器構造函數,例如傳入renderScene和configureScene? :
class practice extends Component {
...
renderScene(route, navigator){
...
}
configureScene(route, routeStack){
...
}
render() {
return (
<Drawer
content={<DrawerPanel navigator={navigator}/>}
...
>
<Navigator
configureScene={this.configureScene}
initialRoute={{name: 'Login', component: Login}}
renderScene={this.renderScene}
style={styles.container}
navigationBar={
<Navigator.NavigationBar
style={styles.navBar}
routeMapper={NavigationBarRouteMapper(this.openDrawer)}
/>
}
/>
</Drawer>
);
}
}
預先感謝您!
更新3 ****
在我<DrawelPanel/>
import HomePage from './HomePage'
render(){
var pr = this.props
var navigator = pr.getNav()
return (
<View style={{flex:1, padding: 30, backgroundColor: 'black'}}>
<MadeButton
componentName={HomePage}
navigator={navigator}
pageName='HomePage'
style={{fontSize:15, fontWeight:'bold', color:'white'}}
/>
</View>
)
然後在我的<MadeButton/>
static propTypes = {
componentName: React.PropTypes.any,
navigator: React.PropTypes.any,
pageName: React.PropTypes.string,
style: React.PropTypes.object
}
_navigate(type='Normal'){
this.props.navigator.replace({
component: this.props.componentName,
type: type,
name: this.props.pageName
})
}
render(){
var pr = this.props;
var st = this.state;
var styles = pr.style;
return(
<TouchableHighlight onPress={() => this._navigate()}>
<Text style={styles}>{pr.pageName}</Text>
</TouchableHighlight>
)
}
我在原帖中增加了更多細節。請看一下。它確實做錯了嗎?我被告知這就是它應該如何設置的。 –
我知道你的意思!我認爲' '它不是可以使用'Navigator'的容器。就像模型不能在0.17.0 –
中使用ScrollView那麼我怎麼能在中使用諸如this.props.navigator.replace()之類的函數呢? –