When to use private custom props?
Really quick question: I use private props a lot
--_private-property
for anything that isn't global.
I have a situation where there's essentially a grid page container that contains the whole page. I feel like that's essentially global so prefixing it with the private property doesn't make a whole lot of sense, but also I'll only be using it within nested classes / elements. Thoughts?5 Replies
there is no such thing as "private properties"
they are all global
you just treat them differently because of the
_
No they aren't
Red's prop won't be accessible outside of itself or children, which means it wouldn't be global (but yes I know the name prefix _ is just convention and doesn't do anything). Moreso the question was if I should prefix it as it isn't accessible outside of the class its in but its essentially wrapping the whole app
I'll only be using it within nested classes / elements.Could you give a simple example of how you'd use it?
Something like this:
Any other time I'd be like 'yea makes sense to put it as a private prop' but since it's basically wrapping the whole page it feels 'global' I guess
(ignore the semantics of if this could be in an aside and outside of main instead I'm just using it as an example haha)
I'd probably do it anyway, but yeah, it could go either way. The benefit of the _ approach isn't a big here.