Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.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 使用meteor和react进行过多递归时出错_Reactjs_Meteor - Fatal编程技术网

Reactjs 使用meteor和react进行过多递归时出错

Reactjs 使用meteor和react进行过多递归时出错,reactjs,meteor,Reactjs,Meteor,我试图在React中创建一个简单的组件来填充表单,但当我运行它时,控制台会显示错误递归太多 我已经尝试删除handleSubmit上的事件.preventDefault(),但没有成功,我还尝试使用{this.props.currentUser?(…):“ 我的代码是下一个: <form onSubmit={this.handleSubmit.bind(this)}> <div className="form-group">

我试图在React中创建一个简单的组件来填充表单,但当我运行它时,控制台会显示错误
递归太多

我已经尝试删除
handleSubmit
上的
事件.preventDefault()
,但没有成功,我还尝试使用
{this.props.currentUser?(…):“

我的代码是下一个:

      <form onSubmit={this.handleSubmit.bind(this)}>
          <div className="form-group">
            <label htmlFor="productName">Product name:</label>
            <input
              className="form-control"
              type="text"
              ref="productName"
              required
            />
          </div>

          <div className="form-group">
            <label htmlFor="productName">Product description:</label>
            <input
              className="form-control"
              type="text"
              ref="productDescription"
              required
            />
          </div>

          <div className="form-group">
            <label htmlFor="productName">Minimum amount increase</label>
            <input
              className="form-control"
              type="text"
              ref="minIncrease"
              required
            />
          </div>
          <input className="btn btn-primary" type="submit" value="Submit" />
        </form>

我发现了错误,它是在
handleSubmit
中缺少
.value.trim()

正确的代码是:

handleSubmit(event) {
    event.preventDefault();

    // Find the txt field via React ref
    const productName = ReactDOM.findDOMNode(
      this.refs.productName
    ).value.trim();
    const productDescription = ReactDOM.findDOMNode(
      this.refs.productDescription
    ).value.trim();
    const minIncrease = ReactDOM.findDOMNode(
      this.refs.minIncrease
    ).value.trim();
...
}

我发现了错误,它是在
handleSubmit
中缺少
.value.trim()

正确的代码是:

handleSubmit(event) {
    event.preventDefault();

    // Find the txt field via React ref
    const productName = ReactDOM.findDOMNode(
      this.refs.productName
    ).value.trim();
    const productDescription = ReactDOM.findDOMNode(
      this.refs.productDescription
    ).value.trim();
    const minIncrease = ReactDOM.findDOMNode(
      this.refs.minIncrease
    ).value.trim();
...
}