Closed amandal97 closed 12 months ago
@amandal97 thanks for the issue, will get this fixed. if you are blocked, for now you can add a key prop to the CheckboxGroup to force rerender it.
<CheckboxGroup key={props.route.auth} \/>
when props.route changes, the consequent re-render is not picking up the new values provided to defaultValue prop.
@amandal97 actually this is an expected behaviour of uncontrolled components.
Changing defaultValue won't change the input's value on consequent re-render, because defaultValue is like an initial value once it's set it won't change between renders.
Here's a codesandbox demo for understanding
Solutions:
key
prop, this is also viable solution if you don't want to manage the state of the checkbox yourself. Closing this as resolved, confirmed by @amandal97
Please consider the below implementation:
Here, when
props.route
changes, the consequent re-render is not picking up the new values provided todefaultValue
prop. This might be becausedefaultValue
is being set as a local state in useControllable hook.Slack Thread
https://github.com/razorpay/blade/assets/45780866/73f1982a-9e1d-41cf-8a1a-4ae1a3257780