如何使用react-native-router-flux从路由器调用场景方法

时间:2018-07-27 09:46:44

标签: react-native react-native-router-flux

我想使用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吗?

或者对我有其他建议吗?

0 个答案:

没有答案