react-native - 将按钮添加到 React Navigation 标题的标题
问题描述
我有我的这个组件......我想在其中绘制一个注销按钮并隐藏后退箭头。但我不能这样做。谁能告诉我我在哪里做错了?我也遵循了反应导航的原始文档,但没有解决方案。
class Welcome extends React.Component {
constructor(props) {
super(props)
this.state = {
user: this.props.navigation.state.params.user,
}
}
static navigationOptions = ({ navigation}) => {
const { params = {} } = navigation ;
return {
headerTitle : "Welcome",
headerLeft: null,
headerRight : (
<TouchableOpacity
style={{ backgroundColor: '#29434e' , padding: 10}}
onPress={() => params.onlogout}
>
<Text style={{ marginVertical:5, color: 'rgba(255,255,255,0.7)', fontSize: 20,}}> Logout </Text>
</TouchableOpacity>
)
};
};
_Logout = () => {
this.props.Signout();
};
componentDidMount() {
this.props.navigation.setParams({ onlogout : this._Logout , isSaving: false})
}
}
}
const mapDispatchToProps = (dispatch) => {
return {
Signout: () => dispatch(Signout())
}
}
export default connect(null,mapDispatchToProps)(Welcome)
解决方案
推荐阅读
- javascript - 检查原始页面时,Google 没有从 amphtml 标记抓取我的 amp 链接
- latex - !LaTeX 错误:出了点问题——可能缺少 \item
- javascript - 如何在 JavaScript 中对两个数组数据求和
- cucumber - 特征创建(Cucumber 测试)
- css - 插值管不适用于大写角度
- c# - 如果选中为真,复选框绑定不会更改值
- javascript - 将模块脚本重写为 JavaScript 中的经典脚本
- python - 如何让机器人搜索特定字符串的整个消息
- vba - 范围的 Excel 动态列引用
- java - 无法从java中的日志文件解析json对象