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