0
如何從新路徑上的passProps獲取參數?從「家」傳遞到「單人」。確認值的解析不知道如何在single.js上檢索它們?React Native - 從PassProps Navigator中檢索值
//index.ios.js
class AwesomeNativeBase2 extends Component {
renderScene(route, navigator) {
if(route.name == 'single') {
return <Single navigator={navigator} />
}
if(route.name == 'home') {
return <Home navigator={navigator} {...route.passProps} />
}
if(route.name == 'update') {
return <Update navigator={navigator} {...route.passProps} />
}
}
render() {
return (
<View style={styles.container}>
<Navigator
initialRoute={{name: 'home'}}
renderScene={this.renderScene.bind(this)}
/>
</View>
);
}
}
//home.js
class Home extends Component {
navigate(routeName, property) {
this.props.navigator.push({
name: routeName,
passProps: {
id: property
}
});
}
//single.js
class Single extends Component {
render() {
console.log(this.props.navigator.pop());
感謝,是我不好,應該的解決了這個問題! –