-
Notifications
You must be signed in to change notification settings - Fork 79
All pure components should accept all DOM props #46
Comments
Oh this has been open for a while and nobody has any comments yet! Let me take take a stab at it :) What's the downside of doing something like: <input {...props} /> in our components? I can see the benefit being for example we don't have to make a PR to cf-ui to make sure that we can disable a toggle which would speed up our process. |
Sure. Let's ID a list of components we want to do this first. As it stands, a lot of the typographic components are not useful at all and I don't see the value of working on them further. There may be others that aren't useful. |
Also, we might not want all props to be expanded, just those we know are accepted by HTML5. |
Ok, we could keep a list maybe of allowed props? What would be the downside of expanding all props? |
I have no good reason to continue with a whitelist approach so far, just something we need to keep in mind. Best go thru all the components now and see if there are idioms in them that have a high probability in resulting accidental overwrites of attributes. |
The only downside I can think of is |
This is a living ticket as PRs that allow arbitrary props to be passed into the cf-ui components are opened and merged, until all components are fixed. |
@wyuenho In order for this to be actively worked on (and maybe one day finished) could you list up the places where we are not passing the props through so we have a idea of how much is left of this ticket? Maybe it even goes hand-in-hand with the fela migration since |
It actually goes against fela migration since I like props validation a lot because it gives us some clear contract and you can see it in docs. If there's something missing just open a PR. Eventually, we will cover everything. It's not that hard. |
I'm going to close this one. There is one and only one practical reason that convinced me passing thru arbitrary props is a bad idea when combined with Fela, which is enough to challenge my initial rationale. When implementing selector heavy styles, where some style props have to propagate from multiple levels down, the component at each level will have to know both what will be passed down implicitly, and what to pass down explicitly. If we allow arbitrary prop spreading, undeclared extra props may be passed all the way down from great grand parent to child unexpectedly. This makes debugging really hard. If the child happen to be leave, we may get React warnings too. |
cf-ui has a ton of pure components that only do 2 things:
The text was updated successfully, but these errors were encountered: