Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 提交时清除后,所需输入字段变为红色。反应_Reactjs_Firefox_Axios - Fatal编程技术网

Reactjs 提交时清除后,所需输入字段变为红色。反应

Reactjs 提交时清除后,所需输入字段变为红色。反应,reactjs,firefox,axios,Reactjs,Firefox,Axios,我有一个表单,它调用redux操作,然后在post成功时清除输入字段。问题似乎是在成功发布后清除输入字段后,输入字段变为红色 重复操作功能 postActionFunction = (data, clearDataFunction) => (dispatch) => { axios .post(`/endpoint`, data) .then(() => { console.log('success'); }) .then(()

我有一个表单,它调用redux操作,然后在post成功时清除输入字段。问题似乎是在成功发布后清除输入字段后,输入字段变为红色

重复操作功能

postActionFunction = (data, clearDataFunction) => (dispatch) => {
  axios
    .post(`/endpoint`, data)
    .then(() => {
      console.log('success');
    })
    .then(() => {
      clearDataFunction();
    })
    .catch((err) => {
      console.log('error');
    });
};
 onSubmit(e) {
    e.preventDefault();
    const { inputData } = this.state;
  // below function is the redux action
    this.props.postCategories(inputData, this.clearDataFunction);
  }

 clearDataFunction() {
    this.setState({ inputData: '' });
  }
表单提交功能

postActionFunction = (data, clearDataFunction) => (dispatch) => {
  axios
    .post(`/endpoint`, data)
    .then(() => {
      console.log('success');
    })
    .then(() => {
      clearDataFunction();
    })
    .catch((err) => {
      console.log('error');
    });
};
 onSubmit(e) {
    e.preventDefault();
    const { inputData } = this.state;
  // below function is the redux action
    this.props.postCategories(inputData, this.clearDataFunction);
  }

 clearDataFunction() {
    this.setState({ inputData: '' });
  }
编辑:
这似乎只会发生在Firefox开发者版上,这取决于您的验证。显示与验证相关的代码。验证发生在后端,不会返回任何链接到输入字段的内容。html可能会有所帮助,因此在Firefox developer's edition上,字段会变为红色,同时控制台会打印单词
success
?假设
success
应该是一个字符串,它只是一个输入错误。是的,字段变为空,控制台中会打印“success”消息。但是田野变红了。
postActionFunction = (data, clearDataFunction) => (dispatch) => {
  axios
    .post(`/endpoint`, data)
    .then(() => {
      console.log('success');
    })
    .then(() => {
      clearDataFunction();
    })
    .catch((err) => {
      console.log('error');
    });
};
 onSubmit(e) {
    e.preventDefault();
    const { inputData } = this.state;
  // below function is the redux action
    this.props.postCategories(inputData, this.clearDataFunction);
  }

 clearDataFunction() {
    this.setState({ inputData: '' });
  }