Replies: 1 comment
-
I think you forgot to save the codesandbox. Just to clarify, in a controlled state, ie, you pass the value prop to a component, we will not call on change in response to you changing the prop. Instead, we call on change when we think you should update your prop. https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi guys, I have a generic question about "Controlled" components. I've noticed that
useControlledState
doesn't call theonChange
callback when "controlled" behavior is enabled.Is this expected behavior for controlled components in general? My expectations were that the "controlled" component should call the
onChange
event if the value changes.I've created a simple test to show:
https://codesandbox.io/s/flamboyant-wildflower-l0ckvp?file=/src/switch.test.js
See how
<Switch />
doesn't call theonChange
event when I change theisSelected
prop.Is this expected?
Beta Was this translation helpful? Give feedback.
All reactions