我想使用react-native-router-flux
在导航栏中创建带有提交按钮的表单。
这是 form.js 的代码:
export default connect(s => s) (
class extends Component {
constructor(props) {
super(props);
this.state = {
label: props.label || "",
address: props.address || ""
};
}
submit() {
// I want to update the store here
let { dispatch } = this.props;
dispatch({ ... });
}
...
})
router.js:
export default () =>
<Router>
<Scene key="root">
<Scene key="Form"
component={Form}
back={true}
rightTitle="Submit"
onRight={() => {
this.submit();
// Can I execute the submit function inside the component?
}}/>
我可以从submit()
属性调用onRight
吗?
或者对我有其他建议吗?