import React from 'react';
import {Fieldset, Field, createValue} from 'react-forms';
export default class Validation extends React.Component {
constructor(props) {
super(props);
this.onChange = this.onChange.bind(this);
this.state = {
value: {},
};
}
onChange(value) {
this.setState({value});
}
render() {
const {value} = this.state;
return (
);
}
}
let schema = {
type: 'object',
properties: {
firstName: {type: 'string'},
lastName: {type: 'string'},
age: {type: 'integer'}
}
};
class Form extends React.Component {
constructor(props) {
super(props);
let formValue = createValue({schema, value: props.value, onChange: this.onChange});
this.state = {formValue};
}
onChange = (formValue) => {
this.setState({formValue});
this.props.onChange(formValue.value);
}
render() {
return (
);
}
}