fk-react-ui-components
Version:
Step 1 : Create a file in [ Seeds / Plants / Trees ] <br> Step 2 : It should export an Object with component name and story Component [Refer other components] <br> Step 3 : Story Component should return a react component <br> Step 3 : Created file should
36 lines (34 loc) • 1.22 kB
JavaScript
import React from "react";
class FormElement extends React.Component {
constructor(props) {
super(props);
this.state = {
value: this.props.initialValue ? this.props.initialValue : "",
name: this.props.name
};
this.handleChange = this.handleChange.bind(this);
// this.makeCustomProps(this.props);
}
// makeCustomProps(props){
// this.customProps = Object.assign({},props);
// this.customProps["validator"] && delete this.customProps["validator"];
// }
handleChange(event, value) {
var eVal = value !== undefined ? value : event.target.value;
this.props.onChangeEvent && this.props.onChangeEvent.call(this.props.context, event);
this.setState({ value: eVal });
this.validate(eVal);
}
componentWillReceiveProps(props) {
props.value && this.setState({
value: props.value
});
}
validate(v) {
if (this.props._formElementStatuschange && this.props.validator) {
this.props._formElementStatuschange(this.props.validator(v), this.state.name);
}
}
}
export default FormElement;
//# sourceMappingURL=FormElement.js.map