[v4] Provide own ref #3092
Replies: 2 comments 2 replies
-
I moved this to the discussions section. Rolling your own refs might seem to be a good idea at first, and initially, it was allowed but people often passed refs created with So the only reliable reactive is the one being internally provided if I can find a way around these edge cases I will be happy to implement them. v4 comes with a different direction when dealing with form values, the premise is that you don't really need Feel free to explain your use-case, what kind of component are you building? why do you need to provide your own ref? |
Beta Was this translation helpful? Give feedback.
-
Thanks for moving it!
Why is this a problem? If the arguments are typed with Ref, users should not be allowed to provide a computed ref. (except they use ts-ignore, but which should nothing to bother about). Or do I miss anything here?
As I said, I usually prefer to build software which does not rely on (too many) third party libraries. So if I would use vee-validate in any form, I have to couple my components to your library. And it is not just the coupling regarding validation, but also the values passed to form. |
Beta Was this translation helpful? Give feedback.
-
As suggested in the documentation, you should use useField for custom form elements.
This may work, but it feels kinda strange to include vee-validate into those, especially if you want to build a public/shared library.
Furthermore if you use useField you always have to rely on it, instead of providing own refs or reactives. It feels kinda strange for me and does not follow the composition principle. It also gets even weirder, if you want to deal with initialValues, which is the case if users want to edit something. It just does not feel natural to me.
To fix those "issues" I see two ways:
Either find a way to provide custom props to the
Field
component or allowuseField
to use an own ref/reactive. So vee-validate only handles for what is it build: validation.This may be seen different by others, but I just wanted to discuss this.
Anyway, @logaretm keep up the good work. Really enjoyed the library in a couple of projects.
Beta Was this translation helpful? Give feedback.
All reactions