-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid this.$refs needs context #6
Comments
Hello @kartsims ! Thank you for this issue. OK, help me out. What I meant is that instead using this.$refs on subcomponents, the subcomponent should provide a good API (props + events). That's why I said "avoid" instead of "don't". I'm not against the use of refs to access DOM elements. How could we write this in a more specific way? |
After trying to change the paragraph I came to the conclusion that it just doesn't belong here. Not like this anyway Using It is still interesting to mention it but maybe in a more general way, at the end of the style guide, in a paragraph like "Improving existing components" or "When should you change the component itself"... Not fan of either title but you get the idea. I believe it would be interesting to mention specific cases. Examples : 1 - Accessing a subcomponent through 2 - Using a I am sure there are plenty of other examples you could think of. The times when you hesitated and thought "hmm maybe this is not standard, there must be a better way" |
What do you think about changing it to: Avoid
|
I agree I think it's pretty clean to access modal open and close method. How would you do it otherwise? |
Use |
I never said its a bad practice @Elfayer . I said its better to avoid it. :) The example you just shown its a good example of when use Check my last comment to see a bad use of this.$refs. Why is it bad? Because that value could be emitted. It makes sense and the component would be isolated. What do you think @Elfayer ? |
@pablohpsilva I think We are talking about using Edit: Or maybe just mention to use it when you know why you use it, not just as a shortcut. Also maybe add this image? |
Yeap! That's exactly it @Elfayer . Guys, help me out writing this style guide: Use
|
@pablohpsilva I added as much details as I could, keep what you like ;) Use
|
I like this version, maybe we could continue the discussion (if need be) in a PR ? |
@pablohpsilva I'll try, but it'll be my first commit ever on GitHub, so I hope I'm not going to break anything. =/ |
This PR was originated from issue pablohpsilva#6 by @kartsims @pablohpsilva @miljan-aleksic
Please tell me if I made any mistake in the process. |
Nope @Elfayer :D |
While reading the paragraph about avoiding
this.$refs
I thought it wasn't clear enough that you mean "avoid it to access subcomponents".this.$refs
can also be used to access any DOM element's native API and in this case it is pretty useful and can't be done otherwise.Would you prefer a PR ?
The text was updated successfully, but these errors were encountered: