Complex control component pattern #2010
-
Just wondered if anyone have any feedback on this pattern for using complex input components with react-hook-form? Basically the idea is to have an internal state and useEffect to call onChange whenever the internal state changes. The component in the CodeSandbox is pretty simple and random, but in theory the internal value could be a lot more complex... ie. a geoJson object defining something a user has drawn on a map right? https://codesandbox.io/s/react-hook-form-custom-input-pattern-lystm?file=/src/index.js |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
honestly, i would build a controlled component and then wrapped with |
Beta Was this translation helpful? Give feedback.
honestly, i would build a controlled component and then wrapped with
Controller
, and let theController
collect whatever data is necessary and with validation.