NewOldMax / react-form-validator-core

Core validator component for react forms
MIT License
94 stars 44 forks source link

Setting props dynamically doesn't work #60

Closed flaviusmatis closed 5 years ago

flaviusmatis commented 5 years ago

I'm trying to set the "instantValidate" property dynamically and there is no effect.

I've also tried to use refs like you suggested here (https://github.com/NewOldMax/react-form-validator-core/issues/33#issuecomment-507669085), and I can successfully alter the property via the ref, but it as no real effect.

NewOldMax commented 5 years ago

Hi. Can you reproduce your issue on https://codesandbox.io/s/new?

flaviusmatis commented 5 years ago

There you go: https://codesandbox.io/s/sleepy-browser-35d30

instantValidate is initially false; after clicking the submit button it becomes true, but instant validation still doesn't work

NewOldMax commented 5 years ago

try to do something like this

  enableInstantValidate = e => {
    this.form.instantValidate = true;
    this.form.childs.forEach(element => {
      element.instantValidate = true;
    });
  };
flaviusmatis commented 5 years ago

Your last suggestion works.

Do you also plan to add support to be dynamically changed or should I stick with this solution?

NewOldMax commented 5 years ago

It's really specific case and I believe it can be done without dynamic changes. So no plans to support it.