-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cure logic bug preventing form.isValid reactivity #1
base: master
Are you sure you want to change the base?
Conversation
When I first created this lib, I was trying to recreate what we had with cerebral, but since then react-hooks has come along and I'm now using that for forms (https://github.com/garth/react-hooks-forms) which is much cleaner IMO. @100ideas it seems like you have invested some time in this PR. Would you be interested to take over the package and NPM publish rights? |
Ah cool, I will check out your react-hooks-forms project! My goal right now is to learn overmind usage patterns that support complex, dynamic interfaces & state - basically spreadsheet apps. So figuring out how your package worked was helpful in that regard. I am going to ask the folks in the cerebral/overmind-project discord channel (https://discord.gg/nByU3ZE) for feedback on the implementation of overmind-form and how I used it in the demo. I want to know how to better use operators and functional techniques for features like form validation and data autocompletion. I am inspired by the way the validation works in your state-forms package. I will definitely check out react-hook-forms. Do you have any plans to add validation or form generation helpers (i.e. automatically create & hook up react components from definition) to react-hook-forms? I would like to help you with your new package or maintain the old one - it just depends on the feedback I get. |
overmind-forms/src/isFormValid.ts
is a derived state function built intoovermind-forms
that makesstate.<your-forms-name>.isValid
reactive.It is broken in
overmind-forms@0.0.4
+overmind@15.1.2
. The function should trigger whenever any field element in theovermind-form
has the propertyisValid: false
, i.e. at a path-value likestate.[overmindForm].[formField].isValid: false
.But location of the isValid boolean is one level deeper, at
state.[overmindForm].[formField].isValid.isValid: false
. This patch fixes the problem by looking one level deeper. A better solution might have been to just move the boolean up one level.Also, the typescript types are too complicated for me, so currently the compiler complains about a type mismatch using this new path. Someone more familiar with typescript could probably fix that in a couple of minutes.