How does react-hook-form set the input default value? #10822
-
I'm trying to extend react-hook-form for my own project. My approach is to wrap the useForm call with my own hook and input modified values the real hook and output modified functions with extra functionality to my code. I'm trying to add a transform property to the register call so that values can be formatted before supplying them into the input (so I can format monetary values or dates and keep a standard data format for "outside components"). I have figured something out for the setValue call by wrapping it with my own, but I don't understand how react-hook-form sets the input initial values. It doesn't seem like that the register call returns defaultValue property or something like it, which makes the most sense to me. Does react-hook-form does some post-value setting with the input ref in an useEffect hook? If so, can I somehow access it and modify it so that it goes through my supplied function? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The default values is set via element |
Beta Was this translation helpful? Give feedback.
The default values is set via element
ref
. You can see the code related to it here and follow it for more information