Skip to content
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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

100ideas
Copy link

overmind-forms/src/isFormValid.ts is a derived state function built into overmind-forms that makes state.<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 the overmind-form has the property isValid: false, i.e. at a path-value like state.[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.

@garth
Copy link
Owner

garth commented Feb 21, 2019

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?

@100ideas
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants