-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Labels
enhancementNew feature or requestNew feature or request
Description
πββοΈ Feature Request
Support for React.forwardRef on custom form elements to accommodate:
- The uncontrolled components pattern
- Third party libraries, such as react-hook-form
π€ Expected Behavior
- Having an optional ref on my custom form component.
π― Current Behavior
- I can use React.forwardRef, but then I would always need to pass in a ref
- I can go without refs, forgoing their benefits
πββοΈ Possible Solution / π» Examples
Implement a utility to share / combine refs. Several similar implementations already exist:
- https://gist.github.com/pie6k/b4717f392d773a71f67e110b42927fea
- https://itnext.io/reusing-the-ref-from-forwardref-with-react-hooks-4ce9df693dd
- https://gist.github.com/ray851107/b97a0e240d6b9262d1d04d85c63ecada
- https://github.com/smooth-code/react-merge-refs/blob/master/src/index.js
π¦ Context
I would like to build robust and accessible custom form components that support both controlled and uncontrolled component patterns.
jherr, bogdansoare, stefanprobst, bluebill1049, hasft and 15 morebluebill1049, francoismassart, karol-majewski and equinusocio
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request