在使用react-native-meteor时,为react-native-navigation添加导航栏按钮
Adding navbar buttons to react-native-navigation while using react-native-meteor
我将react-native-navigation与react-native-meteor结合使用。从Meteor 1.3开始,建议在使用React时使用createContainer方法。但是,如果我从类定义中删除"导出默认"并将其移动到导出默认createContainer(params=>{…}, MyClass),我松散了导航栏按钮的定义。我该怎么写才能不让导航栏按钮的定义松散?谢谢:)
下面是我的组件的全部代码:
import React, {Component} from 'react';
import {
Text,
View,
StyleSheet,
} from 'react-native';
import Meteor, { createContainer } from 'react-native-meteor';
class TestScreen extends Component {
static navigatorButtons = {
rightButtons: [{
title: 'Reset',
id: 'resetButton'
}, {
title: 'Submit',
id: 'submitButton'
}]
};
constructor(props) {
super(props);
this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(
this));
}
render() {
return ( < View > < Text > Some text < /Text>
</View > );
}
onNavigatorEvent(event) {
if (event.type == 'NavBarButtonPress') {
if (event.id == 'resetButton') {
// reset here
}
if (event.id == 'submitButton') {
// submit here
}
}
}
}
export default createContainer(params => {
const handle = Meteor.subscribe('records');
return {
records: Meteor.collection('records').findOne(),
};
}, TestScreen);
您可以在navigator:
上动态设置它们。this.props.navigator.setButtons({
rightButtons: [
{ title: 'Reset', id: 'resetButton' },
{ title: 'Submit', id: 'submitButton' }
]
});
相关文章:
- React Native通过Navigator将用户输入数据传递到选项卡栏IOS中的组件
- 使用Jest测试React Native应用程序
- 是否存在React Native“;WEB代码安全防护”;
- React Native Listview留有余地
- 如何在React Native中绘制图形
- 在iOS和Android上使用React native时,我还能使用本机第三方lirbraries吗
- 使用createContainer将Meteor数据获取到React Native中时出现问题
- React Native当前是否支持访问用户'的通讯簿
- React Native-What'It’在任何地方都要留下逗号
- React Native DeviceEventEmitter键盘WillShow停止工作
- 与React Native的Chart.js等效
- 在 React-native 中按下按钮时向文本输入值添加一个
- JavaScript-添加图像:React Native XCode
- 你能给React Native Router添加一个BarTintColor吗
- 在 React Native 中 - 是否可以在通过道具接收的动画值上添加侦听器
- 我刚刚添加了 var React = require('react-native');我的整个构建失败了
- 为什么可以't我在react native中以编程方式添加到道具中
- 在使用react-native-meteor时,为react-native-navigation添加导航栏按钮
- 在react native listview中添加动态本地图像
- 如何在React Native中添加自定义字体而不使用Xcode