-
Hi. Could you tell me how to solve the content of the title? version 7.19.5
I tried using React.forwardRef with reference to other people's problems, but the error still appears. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Can you provide a simple codesanbox with the used |
Beta Was this translation helpful? Give feedback.
-
Alright, first, I should say that I've never used Headless UI in production, so I'm not aware of all the quirks of the library (which I see many of lol). Now, the I've managed to hack together a working example by providing my own button element as a child of the Let me know what you think. You might wanna ask this question in the Headless UI repo to better understand how their components were intended to work. You can reference this discussion by adding |
Beta Was this translation helpful? Give feedback.
-
So Like so: <Controller
name="name"
control={control}
defaultValue={reviewedRef?.name}
render={({ field }) => {
const {ref, ...rest} = field; // removes ref
return <SwitchButton {...rest} />
}}
/> This is especially useful if you don't need the ref anyway. Hope that was helpful. |
Beta Was this translation helpful? Give feedback.
Alright, first, I should say that I've never used Headless UI in production, so I'm not aware of all the quirks of the library (which I see many of lol).
Now, the
Switch
component does expose theref
prop, which doesn't get.. forwarded (?) to thebutton
component that is the default component rendered if not altered via theas
prop. I don't have time to actually look into the implementation, sadly.I've managed to hack together a working example by providing my own button element as a child of the
Switch
component. I've addedas={Fragment}
to avoid rendering the defaultbutton
component Headless UI provides. All the a11y button attributes are propagated to the newly providedbutton
elemen…