What is the preferred `Input` usage style: control...
# compose-web
n
What is the preferred
Input
usage style: controlled or uncontrolled? How can I decide?
a
I think that controlled is useful in most simple cases and uncontrolled for complicated scenarios.
👍🏻 1
So use controlled while you can
👍🏻 1
🙏 1
Reasons to have both are same as in react : https://reactjs.org/docs/uncontrolled-components.html
Copy code
Since an uncontrolled component keeps the source of truth in the DOM, it is sometimes easier to integrate React and non-React code when using uncontrolled components. It can also be slightly less code if you want to be quick and dirty. Otherwise, you should usually use controlled components.
🙏 1
1
o
If you're implementing a new component you can make "controlled" only for the beginning until you see a need to have it uncontrolled.
🙏 1
o
So at least in my MDC use case, it's just the opposite: Easier to integrate in controlled mode. I'll be following that path until YAGNI evaluates to
false
.