@material-ui/utils: useControlled() have a different behavior than native primitives #25277
Closed
2 tasks done
Labels
out of scope
The problem looks valid but we won't fix it (maybe we will revisit it in the future)
package: utils
Specific to the @mui/utils package
Hey folks!
Thanks for your contribution into OSS, I am often gathering ideas in your code ❤️
I was testing different implementations of hooks that are implementing autocontrolled behavior for custom components. There is one inconsistency that I found in useControlled() between native primitives.
Current Behavior 😯
Uncontrolled component cannot become controlled 🟥
Expected Behavior 🤔
Uncontrolled component can become controlled ✅
Steps to Reproduce 🕹
I am not using an official template as CodeSandbox have been prepared before.
https://codesandbox.io/s/react-use-controlled-7sen6
Steps:
Context 🔦
It's not affecting me in any way, but I think that it will be nice to align with the behavior of native primitives.
https://github.com/mui-org/material-ui/blob/b96916d373096570b96db101e0ceca25f7ca9346/packages/material-ui-utils/src/useControlled.js#L6
This line is responsive for the current behavior: computed once value will never change. If you have reasons to keep current behavior, please post them 😺
Your Environment 🌎
@material-ui/utils@5.0.0-alpha.27
The text was updated successfully, but these errors were encountered: