Replies: 1 comment
-
|
You can use the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Before you read
I know this is a bit of a XY Problem but I want to make a component that doesn't force me to wrap evrything in a
Providerthat provides ALLFieldcontext, because I know I'm going to forget to add some context at some point and go down a debugging rabbithole 😂What I really want is something like this discussion is describing:
But I see that it has not been discussed any further, so I tried to make it work without it.
The Problem
I have a case where I want to create a composable API for form fields in a component library.
Mainly I want to be able to have one or more fields share one description and error message.
Ignore the naming of stuff here, it's WIP 😅
.
The API I'm trying to achieve:
Current State
I've basically got it working by making the following component, with a util function
enhanceChildrenthat addsaria-describedBy,aria-errormessageandaria-invalidto the field-component children of theFormControl.Only problem I'm having atm to match the regular implementation of the Field-pattern is that the
RACValidationErrorswon't render. The component looks like this:The
FieldErrorhere ☝️ returnsnullbecause theFormFieldContextsvalidationobject hasisInvalidequal tofalse.I'm assuming this is because It's not child of a XYZFieldProvider.
Anyone got any tips?
Beta Was this translation helpful? Give feedback.
All reactions