You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
The current implementation of the BSSwitch component in the kotlinbs library uses the defaultChecked attribute to set the initial state of the switch. This approach does not allow for dynamic updates to the switch state after the initial render. As a result, changes to the switch state are not reflected in the UI when the underlying state changes.
Expected Behavior
The BSSwitch component should update its checked state dynamically based on the checked attribute. This will ensure that any changes to the underlying state are accurately reflected in the UI.
Proposed Solution
Modify the BSSwitch component to use the checked attribute instead of defaultChecked. The checked attribute will be passed as a parameter to the BSSwitch function, allowing it to update dynamically.
I haven't been able to reproduce the issue with the provided code. When I click the BSSwitch component it does indeed changes/updates it's state. However I may update the name of the parameter from defaultChecked to isChecked or checked. Your solution also works well btw.
var isChecked by remember { mutableStateOf(false) }
BSSwitch(
label ="Example Switch",
defaultChecked = isChecked,
onClick = {
isChecked = it
}
)
Description
The current implementation of the BSSwitch component in the kotlinbs library uses the defaultChecked attribute to set the initial state of the switch. This approach does not allow for dynamic updates to the switch state after the initial render. As a result, changes to the switch state are not reflected in the UI when the underlying state changes.
Expected Behavior
The BSSwitch component should update its checked state dynamically based on the checked attribute. This will ensure that any changes to the underlying state are accurately reflected in the UI.
Proposed Solution
Modify the BSSwitch component to use the checked attribute instead of defaultChecked. The checked attribute will be passed as a parameter to the BSSwitch function, allowing it to update dynamically.
Current Issue example:
Proposed Solution
The text was updated successfully, but these errors were encountered: