-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Explore strategies for enabling fully controlled components #2489
Comments
We've marked this issue as stale because there hasn't been any activity for a couple of weeks. If there's no further activity on this issue in the next three days then we'll close it. Thanks for your contributions. |
Hi there! 👋 If you're wondering why this issue was moved, we're currently updating our repo structure so that every package is found in the same project. This should not have any impact for you, but we wanted to give you a heads up in case you were wondering what is going on. If you have any questions, feel free to reach out to us on Slack or contact us at: carbon@us.ibm.com. Thanks! |
This change turns `<NumberInput>` to "controlled mode", if `onChange` prop exists. Refs carbon-design-system#2489.
We've marked this issue as stale because there hasn't been any activity for a couple of weeks. If there's no further activity on this issue in the next three days then we'll close it. You can keep the conversation going with just a short comment. Thanks for your contributions. |
This change turns `<NumberInput>` to "controlled mode", if `value` prop exists. Refs carbon-design-system#2489.
This change turns `<NumberInput>` to "controlled mode", if `value` prop exists. Refs carbon-design-system#2489.
This change turns `<NumberInput>` to "controlled mode", if `value` prop exists. Also this change introduces `readOnly` prop to `<NumberInput>` with corresponding style. Refs carbon-design-system#2489. feat(NumberInput): support readOnly
This change turns `<NumberInput>` to "controlled mode", if `value` prop exists. Such "controlled mode" switch is behind `useControlledStateWithEventListener` feature flag for now to given it's a breaking change. Also this change introduces `readOnly` prop to `<NumberInput>` with corresponding style. Refs carbon-design-system#2489.
This change turns `<NumberInput>` to "controlled mode", if `value` prop exists. Such "controlled mode" switch is behind `useControlledStateWithValue ` feature flag for now to given it's a breaking change. Also this change introduces `readOnly` prop to `<NumberInput>` with corresponding style. Refs #2489.
We've marked this issue as stale because there hasn't been any activity for a couple of weeks. If there's no further activity on this issue in the next three days then we'll close it. You can keep the conversation going with just a short comment. Thanks for your contributions. |
As there's been no activity since this issue was marked as stale, we are auto-closing it. |
Summary
Problem: We want to give developers as much control as possible over the state of their application. However, we don't want to require developers to totally manage the state of each component.
I believe we should explore patterns that allow a component to be uncontrolled by default, but permit developers to use them in a controlled fashion should they so choose.
Info on controlled & uncontrolled components.
Justification
Some components can operate simultaneously as both controlled and uncontrolled in a single instance. This causes conflicting states and buggy components behavior.
Currently, for fully controlled components, developers must use a key to force re-renders. This works, and is a recommended alternative to the issue mentioned above, however a new/random key might not always be available and using one results in a hacky developer experience.
To get around this, we've been using
getDerivedStateFromProps
. While this works in some instances, the implementation is often tough to reason about and can greatly complicate component logic especially if there are multiple controlled props.getDerivedStateFromProps
is a static method that shouldn't care about a specific instance's state.The React team covered our exact work around/implementation here and discussed it's buggy nature.
More info: You Probably Don't Need Derived State
Desired UX and success metrics
"Must have" functionality
Milestone: Tech Debt Q2/Q3
PR incoming
The text was updated successfully, but these errors were encountered: