I have a component with state like. I am creating dynamic form, all is working fine but I want to reset the form value once submit button clicked. for that i have a helper function called resetForm() , but unfortunately the logic is not working. can anybody help with this..
state = {
expenseForm: {
date: {
elementType: 'input',
elementConfig: {
type: 'date',
placeholder: 'Enter Date..'
},
value: '',
validation: {
required: true,
isDate: true
},
valid: false,
touched: false
},
category: {
elementType: 'select',
elementConfig: {
options: !this.props.loading ? transformCategory(this.props.categories): null
},
value: transformCategory(this.props.categories)[0].value,
validation: {
required: true,
minLength: 4
},
valid: true,
touched: false
},
description: {
elementType: 'input',
elementConfig: {
type: 'text',
placeholder: 'Enter Description..'
},
value: '',
validation: {
required: true,
minLength: 6
},
valid: false,
touched: false
},
amount: {
elementType: 'input',
elementConfig: {
type: 'number',
placeholder: 'Enter amount..'
},
value: '',
validation: {
required: true,
minLength: 1
},
valid: false,
touched: false
}
},
formIsValid: false
}
resetFormmethod in the question?