您好,我遇到Flow和React问题。
我收到这些错误,我想摆脱它们。我错过了什么我到处搜索。我知道道具遗失了,但我似乎无法找到定义它们的位置。
流程:属性className
。在React元素form
流程:属性onSubmit
。在React元素form
export default class LoginForm extends React.Component {
_submitForm: Function;
constructor(props?: {}) {
super(props);
this.state = {
form: {
email: '',
password: '',
},
errors: {
_form: "",
email: "",
password: ""
}
};
this._submitForm = this._submitForm.bind(this);
}
_handleValues(param: string, value?: string) {
let obj = this.state;
obj['form'][param] = value;
this.setState(obj);
}
_submitForm(event: Event) {
this._clearErrors(event);
let form = this.state.form;
AxiosQueue
.post({
url: LINK.AUTHENTICATE,
data: form
})
.then(({data}) => {
if (!data.success) {
return;
}
})
.catch((response) => {
console.error(response);
});
}
render() {
const {errors, form} = this.state;
const user = UserStore.getUser();
const formText = FORM_TEXT[user.language || "en_AU"];
return (
<form className="form-inline" onSubmit={this._submitForm}>
{errors._form}
<InputEmail id="email" error={errors.email} value={form.email} callback={this._handleValues}/>
<InputPassword id="password" error={errors.password} value={form.password}
callback={this._handleValues}/>
<button type="submit" className="btn btn-default">{formText.LOGIN}</button>
</form>
);
}
}
答案 0 :(得分:1)
Syntex form
和const {errors, form} = this.state;
组件中的变量名称form
存在冲突。解决方案是在this.state
中提供其他名称。喜欢
this.state = {
formValidation:{
//Validation properties
}
}
消费以便消除冲突
const {formValidation} = this.state