are @react-aria/*
packages more than "accessible primitives" now?
#5458
csantos1113
started this conversation in
General
Replies: 1 comment 4 replies
-
We are certainly adding more features to React Aria to make it easier to use, but I wouldn't consider form validation to be outside its realm. In our case, we are mostly just wrapping the native HTML form validation with a nicer API. If you want to use a separate form library that's also fine – all of the built-in features can be turned off, and they are pretty small so shouldn't affect much. Native validation is nice, but we know that people are mixing our components with others so external form libraries are also supported. As long as it's not getting in the way of anything it seems fine to me. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
after seeing the work done in #5288 that introduced form validation to the
@react-aria
packages I have a couple clarifying questions regarding the intention of@react-aria/*
pkgs and specifically about form integration with external libraries like react-hook-form1️⃣ Are
@react-aria/*
hooks doing more than what they were originally intended to do?from https://react-spectrum.adobe.com/react-aria/:
I've used these hooks as low-level elements that give me the correct accessible props as well as event handlers for my components to work (aria-*, focus, hover, labelling, etc) where I just passed some props in and these hooks gave me props back for my HTML elements to be accessible.
But specifically talking about
@react-aria/textfield
(useTextField
hook) (and other fields) there is a lot of logic that I wonder if they are truly part of the "accessible hook primitives", and/or if they should be moved somewhere else:react-spectrum/packages/@react-aria/textfield/src/useTextField.ts
Line 139 in 75417bb
react-spectrum/packages/@react-aria/textfield/src/useTextField.ts
Line 140 in 75417bb
react-spectrum/packages/@react-aria/textfield/src/useTextField.ts
Lines 142 to 158 in 75417bb
react-spectrum/packages/@react-aria/textfield/src/useTextField.ts
Lines 207 to 208 in 75417bb
2️⃣ form-validation in
@react-aria/*
plus react-hook-form integrationI see there is a documentation section for how to integrate with react-hook-form https://react-spectrum.adobe.com/react-aria/forms.html#react-hook-form; but after navigating through the code
there is a lot of JS running always, regardless if the validation is handled from the outside (in our case, by react-hook-form itself).
It seems to me that we have 2 validation mechanisms running at the same time, so I wonder if there is a way to opt-out of
@react-aria
validation and let the third-party handle the validation for us?which piggybacks to my 1️⃣ question: should these primitive hooks stay "dumb" and move that extra logic somewhere else?
I appreciate your help talking through these points and what would be the overall roadmap 🙏
Beta Was this translation helpful? Give feedback.
All reactions