我正在尝试将道具从登录屏幕传递到整个应用程序,因为每个获取请求都取决于用户凭据,所以我该如何实现。
routeConfig文件:
123456/posts?since=07-12-2017&until=10-12-2017
根导航:
export const sendStack = StackNavigator({
send:{
screen:Send,
},
confirm:{
screen:ConfrimPay,
}
});
export const transactionStack = StackNavigator({
transaction:{
screen:Transaction,
},
details:{
screen:Details,
}
});
export const Tab=TabNavigator({
send:{
screen:sendStack,
},
receivers:{
screen:Receipt,
tabBar:{
swipeEnabled:false
}
},
transaction:{
screen:transactionStack
},
},
{
tabBarPosition: 'bottom',
swipeEnabled: false,
tabBarOptions: {
activeTintColor: 'white',
labelStyle:{
fontSize:5
}
}
}
);
export const Logst =StackNavigator({
first:{
screen:First
},
login:{
screen:App ,
},
tab:{
screen:Tab,
},
},
{
headerMode: 'none',
navigationOptions: {
headerVisible: false,
}
});
这是我的登录页面,我使用this.props.navigation.navigate(' tab',{user:user,pwd:pwd});并且它给我一个错误,意味着道具尚未通过
import React, { Component } from 'react';
import {Tab, Logst,Root} from './mainNav';
import App from './App';
class List extends Component {
render() {
return(<Logst />) ;
}
}
注意* 我将stackNav中的道具传递给嵌套在TabNav中的stackNav