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
23 lines (21 loc) • 701 B
JavaScript
import React from "react";
import {isSubmitButton} from "../FormElements.js";
/* "this" context refers to FormComponent instance */
export function ButtonInstanceHandler(o){
if(isSubmitButton(o.type)){
o = React.cloneElement(o, {
onClick : (e)=>{
this.setState({
isSubmitRequested:true
});
this.validate();
if(!(this.errorObj && this.errorObj.validationError)){
this.props.onSuccess && this.props.onSuccess(this.values);
}
e.preventDefault();
},
disabled: this.state.validationError
})
}
return o;
}