当我不将组件连接到redux时,将显示Header(作为登录名),但是当我连接时,将不显示标题,其标题为空白 我尝试了两种选择
class Login extends Component {
static navigationOptions = {
headerTitle: 'Login'
}
...
}
const mapStateToProps = (state) => {
return {
items: [...state.items]
}
}
const ConnectedLogin = connect(mapStateToProps)(Login)
export default ConnectedLogin
第二种方法
class Login extends Component {
...
}
const mapStateToProps = (state) => {
return {
items: [...state.items]
}
}
const ConnectedLogin = connect(mapStateToProps)(Login)
ConnectedLogin.navigationOptions = () => {
title: 'Login'
}
export default ConnectedLogin
如果我仅导出组件而不登录,则会显示标题
export default class Login extends Component {
...
}
我无法弄清我想念的东西
我已经创建了这样的堆栈导航器
const LoginNavigator = StackNavigator(
{
Login: {screen: Login},
MainScreen: {screen: MainScreen},
}
)