Skip to content
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

Checkbox component does not have controlled state #766

Open
rayyan224 opened this issue Aug 8, 2022 · 2 comments
Open

Checkbox component does not have controlled state #766

rayyan224 opened this issue Aug 8, 2022 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@rayyan224
Copy link
Collaborator

The checkbox component should have a controlled state i.e props should directly control what the view is showing.
Here's an example where it doesn't, we want props and state to be tightly coupled in order to reduce memory leaks.

Screen Shot 2022-08-08 at 12 02 20 PM

@rayyan224 rayyan224 added the bug Something isn't working label Aug 8, 2022
@BillyG83 BillyG83 added the help wanted Extra attention is needed label Oct 18, 2022
@surajgjadhav
Copy link

Hi,
I found the root cause of that issue and also observed checkbox is not behaving properly for "Box on by Default" story.

web3uiCheckbox-issue.mp4

This issue was happening. because, their is state issue in component itself.
We need to pass state variable to the checked prop instead of passing the argument variable.


this should be:

checked={isChecked}

should align with state variable instead of normal argument
and our checked argument variable is kind of initial value of checkbox. so, ideally we should remove it from control as we can't align it with state.

If this is accepted please assign this to me and I will raise PR for that.

Thanks

@surajgjadhav
Copy link

Hi @BillyG83 ,
Could you please confirm on this:

Hi, I found the root cause of that issue and also observed checkbox is not behaving properly for "Box on by Default" story.

web3uiCheckbox-issue.mp4
This issue was happening. because, their is state issue in component itself. We need to pass state variable to the checked prop instead of passing the argument variable.

this should be:

checked={isChecked}

should align with state variable instead of normal argument and our checked argument variable is kind of initial value of checkbox. so, ideally we should remove it from control as we can't align it with state.

If this is accepted please assign this to me and I will raise PR for that.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants