-
Notifications
You must be signed in to change notification settings - Fork 75
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
Use key
, ref
and static
props instead of the variants
#259
Comments
I don't mind the existing behavior, especially with the Out of curiosity, why can't the |
@canadaduane The |
Personally, I would use two sets like so (since we already have $-prefixed props):
This makes it less "magical" in the sense that if props are passed to the component, they are readable by the component. And if they have special $ syntax, maybe that breaks the rule. My 2c :) |
Interesting compromise! I haven’t sincerely thought about the actual deep reasons for erasing special props from component props to be honest so I’m not sure about the advantage of this distinction in behavior. Even in the use-case where we want to access a key and ref from within a component, my guess is that this could probably be done as a computed property on the context, as in The main reason I want to use un-prefixed special props is that a lot more code is written by machines and they get it wrong. In an age of LLMs, it’s better to just be cross-compatible. I still think that it’s kind of weird that we’re just not allowed to write components or HTML with the props/attributes I dunno! It all feels like small stuff, it’s tough to make a decision. |
It seems good to lean towards giving more power to the app developer unless there are good reasons not to. As you've mentioned, |
Implemented in 0.6 |
Related to #90
For the longest time, I wanted to use special sigils to distinguish virtual DOM properties like
key
andref
from normal DOM props. It started with a convention where special props were namedcrank-key
andcrank-ref
. This was shortened toc-key
andc-ref
in a later version, and finally shortened even further to$key
and$ref
. My primary rationalization was thatkey
andref
are neither properties nor attributes on the DOM, and I didn’t want to step on the names for custom elements.I now consider this to be a lapse of judgment, and for that I am deeply sorry to all three of my Crank users. The reality is that these prop names are already likely poisoned due to the popularity of React, so that no one would likely ever define properties or attributes named
key
orref
anyways. Furthermore, this minor difference from React can cause a lot of confusion.Going forward, the special props
key
,ref
andstatic
will all be unprefixed. This should land in the next minor version (0.6.0).The text was updated successfully, but these errors were encountered: