form-atoms / form-atoms

Atomic form primitives for Jotai

Home Page:https://codesandbox.io/s/getting-started-with-form-atoms-v2-ddhgq2?file=/src/App.tsx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Direct DOM mutation for fields

loganvolkers opened this issue · comments

Is your feature request related to a problem? Please describe.

React hook form has shown that direct DOM manipulation works in place of the classic react controlled component pattern.

Describe the solution you'd like

Improve hooks and examples to support this pattern.

Describe alternatives you've considered

React controlled components, or a wrapper around field atom.

Additional context

Great library, well typed and documented! Happy to contribute PRs.

Thanks for commenting! I made this library because I dislike react-hook-form uncontrolled components and formik has poor re-render optimization. They're almost never what you want in my experience and I have struggled mightily to get them to work for a wide range of use cases. Lastly, I think if you want uncontrolled inputs you don't really need a library for that - just read the form values on submit. Hence the feature bullet:

  • Controlled inputs because no, uncontrolled inputs are not preferrable

I think you'll find that this library performs just as well in the real world - probably better when you're creating a form with complex validations and dependencies.

For those reasons and for the sake of less API surface area (react-hook-form is confusing in this way, too), I would not accept a PR adding uncontrolled inputs.