我正在使用mobx-react-from,我有一个问题,我不知道如何在obSubmit钩子中使用我的商店中的操作。
mobx表单运行正常..我可以看到输入和验证,当我提交表单时,我想要的就是使用store中的操作……
我的AutStore文件:
import {observable,action} from 'mobx';
class AuthStore {
constructor(store) {
this.store = store
}
@action authLogin=(form)=>{
this.store.firebaseAuth.signInWithEmailAndPassword().then(()=>{
}).catch(()=>{
})
}
}
export default AuthStore我的AuthForm文件:
import {observable, action} from 'mobx';
import MobxReactForm from 'mobx-react-form';
import {formFields,formValidation} from './formSettings';
const fields = [
formFields.email,
formFields.password
];
const hooks = {
onSuccess(form) {
// Here i want to use an action - authLogin from my AuthStore
console.log('Form Values!', form.values());
},
onError(form) {
console.log('All form errors', form.errors());
}
};
const AuthForm = new MobxReactForm({fields}, {plugins:formValidation,
hooks});
export default AuthForm我想知道怎样才能连接到一起谢谢!
https://stackoverflow.com/questions/47620273
复制相似问题