React-final-form ignores Field validate property change

﹥>﹥吖頭↗ 提交于 2019-12-24 07:46:50

问题


On click on a checkbox, I'm changing the "validate" property of another field. The problem is the following: "validate" field is changed and I can see it in React inspector, but react-final-form calls an old validator.

You can see a demo here: https://codesandbox.io/embed/nny0zxz4rm If you click on the checkbox and then Submit - form will be submitted and validator ignored. If you click the checkbox twice - nonrequired field will prevent form submit.

I can't change the validator's code and can't see any other options to fix this issue.


回答1:


This does look like a bug. The field-level validation was not designed with the idea of swapping validation functions so quickly like this. However, until this is fixed, there is a way to accomplish this. https://codesandbox.io/s/pyr69znvnq



来源:https://stackoverflow.com/questions/55380784/react-final-form-ignores-field-validate-property-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!