Availity / availity-reactstrap-validation

Easy to use React validation components compatible for reactstrap.
https://availity.github.io/availity-reactstrap-validation/
MIT License
191 stars 70 forks source link

Uncaught (in promise) TypeError: Cannot read property 'validations' of undefined #157

Open AbhaysinghBhosale opened 4 years ago

AbhaysinghBhosale commented 4 years ago

Getting this issue when AvFields are rendered dynamically. AvForm.js:525 Uncaught (in promise) TypeError: Cannot read property 'validations' of undefined my code is as follows `

{this.renderFormFeild()} {this.renderButton()} ` renderFormFeild() function returned different form field as per current state and state get changed on radio outside the form. When i change any text in input field get this issue.
GoPro16 commented 4 years ago

It sounds like you may be setting up your form fields wrong. Make sure you are using the name prop when creating each input. That is the name that gets registered with the form validation context and returns all of those validations that you are seeing as undefined.

AbhaysinghBhosale commented 4 years ago

@GoPro16 i have two type of form fields/input. Type 1 fields returned if state is true and Type 2 fields are returned if state is false.

In the DOM i can see the field with name attr. but on input focus/change it triggers error.

GoPro16 commented 4 years ago

Can you please post a code sandbox link with your issue. There may just be some minor configuration you are doing wrong or its an edge case bug that I cannot seem to follow.

JonoAugustine commented 4 years ago

I'm also getting this err. It comes up when trying to insert a field into a form with another component:

  const EVField = props_ => (
    <AvField
      type="number"
      validate={{
        min: { value: 0 },
        max: { value: 252 }
      }}
      name={props_.name} />
  );

<AvForm>
   <EVField name="name" />
</AvForm>
millerf commented 4 years ago

I am getting the same error. It looks like it is coming the name. I am using a form to create some array this way: <AvField required type="date" name={'partialShipment[' + index + '][endOfProduction]'} id={'partialShipment[' + index + '][endOfProduction]'} /> and that seems to be the problem...

hpsharon commented 4 years ago

Hi,

anyone has a solution for it?

ReneGustavo commented 2 years ago

Anyone has a solution for it?

What happened to @JonoAugustine also happens to me.