我在使用具有正常反应应用的formy-react模块时遇到问题。我一直在autoGenerateWrapperClass of react中遇到一个type.toUpperCase()异常。
我已经逐字地从GitHub页面复制了这些示例。我的表格类是;
var React = require('react');
var ReactDOM = require('react-dom');
var Formsy = require('formsy-react');
var Form = Formsy.Form;
var MyOwnInput = require('./MyOwnInput.jsx');
var MyAppForm = React.createClass({
getInitialState: function () {
return {
canSubmit: false
}
},
enableButton: function () {
this.setState({
canSubmit: true
});
},
disableButton: function () {
this.setState({
canSubmit: false
});
},
submit: function (model) {
someDep.saveEmail(model.email);
},
render: function () {
return (
<Form onValidSubmit={this.submit} onValid={this.enableButton} onInvalid={this.disableButton}>
<MyOwnInput name="email" validations="isEmail" validationError="This is not a valid email" required/>
<button type="submit" disabled={!this.state.canSubmit}>Submit</button>
</Form>
);
}
});
和我的自定义输入类;
var React = require('react');
var Formsy = require('formsy-react');
var Mixins = Formsy.Mixin;
var MyInput = React.createClass({
// Add the Formsy Mixin
mixins: [Mixins],
// setValue() will set the value of the component, which in
// turn will validate it and the rest of the form
changeValue: function(event) {
this.setValue(event.currentTarget[this.props.type === 'checkbox' ? 'checked' : 'value']);
},
render: function() {
// Set a specific className based on the validation
// state of this component. showRequired() is true
// when the value is empty and the required prop is
// passed to the input. showError() is true when the
// value typed is invalid
var className = this.props.className + ' ' + (this.showRequired() ? 'required' : this.showError() ? 'error' : null);
// An error message is returned ONLY if the component is invalid
// or the server has returned an error message
var errorMessage = this.getErrorMessage();
return (
<div className='form-group'>
<label htmlFor={this.props.name}>{this.props.title}</label>
<input type={this.props.type || 'text' }
name={this.props.name}
onChange={this.changeValue}
value={this.getValue()}
checked={this.props.type ==='checkbox' && this.getValue() ? 'checked' : null} />
<span className='validation-error'>{errorMessage}</span>
</div>
);
}
});
module.exports = MyInput;
我正在使用Browserify来补充JSX,如果这有所不同。
有谁知道这是从哪里来的?