tcomb-form
tcomb-form copied to clipboard
Expected component class got [objet,object]
Version
Tell us which versions you are using:
[email protected] └─┬ [email protected] └── [email protected] react-native-cli: 2.0.1 react-native: 0.40.0
i am trying to use tomb-form for the first time and using ES6 features and having issues. can you please tell me what is wrong with code.
import React, {Component} from 'react' import t from 'tcomb-form' var Form = t.form.Form;
// define a model const Expense = t.struct({ description: t.Str, // two string properties comments: t.Str });
export default class ExpenseFormView extends Component{
constructor(props){
super(props);
this.state = {
value: {
description: 'Giulio',
comments: 'Canti'
}
}
}
onClick() { var value = this.refs.form.getValue(); // getValue returns null if validation failed if (value) { console.log(value); } }
onSubmit(){ console.log('submitted..'+ this.refs.form.getValue()); }
render() { return ( <form onSubmit={this.onSubmit}> <t.form.Form ref="form" type={Expense} value={this.state.value}/> <div className="form-group"> <button type="submit" className="btn btn-primary">Save ); } }
module.exports = ExpenseFormView;