GithubHelp home page GithubHelp logo

Comments (10)

jwineman avatar jwineman commented on May 18, 2024 2

The only downside I can think of is propTypes don't warn when you pass in extra props. I can't think of any scenarios where this would actually affect us negatively though.

from cf-ui.

koddsson avatar koddsson commented on May 18, 2024

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.

from cf-ui.

wyuenho avatar wyuenho commented on May 18, 2024

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.

from cf-ui.

wyuenho avatar wyuenho commented on May 18, 2024

Also, we might not want all props to be expanded, just those we know are accepted by HTML5.

from cf-ui.

koddsson avatar koddsson commented on May 18, 2024

Ok, we could keep a list maybe of allowed props? What would be the downside of expanding all props?

from cf-ui.

wyuenho avatar wyuenho commented on May 18, 2024

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.

from cf-ui.

wyuenho avatar wyuenho commented on May 18, 2024

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.

from cf-ui.

koddsson avatar koddsson commented on May 18, 2024

@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 createComponent accepts a passThroughProps parameter?

from cf-ui.

tajo avatar tajo commented on May 18, 2024

It actually goes against fela migration since createComponent needs a white list of props that should pass through (passThroughProps ). Although, it's probably going to change since it's not a good approach.

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.

from cf-ui.

wyuenho avatar wyuenho commented on May 18, 2024

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.

from cf-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.