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

ToggleSwitch Component is not updated based on the checked prop #1220

Open
Hkbm77 opened this issue Apr 20, 2022 · 0 comments
Open

ToggleSwitch Component is not updated based on the checked prop #1220

Hkbm77 opened this issue Apr 20, 2022 · 0 comments

Comments

@Hkbm77
Copy link

Hkbm77 commented Apr 20, 2022

Issue Type

Bug Report

Component or Pattern Affected

ToggleSwitch

Expected Behavior

When the checked prop is updated from the parent component the toggle switch has to change based on the checked prop passed.

Current Behavior

ToggleSwitch is uncontrollable and not updating based on the checked prop.

Possible Solution

1.Need to remove the state updation on click of the switch this.setState ({ isToggleOn: !this.state.isToggleOn });
2. Need to make sure the passed checked prop is reflecting with the toggle switch.

Steps to Reproduce (for bugs)

  1. Render the ToggleSwitch passing the checked and onChange prop
  2. Try to update the checked state from the parent component.
  3. Notice that changed checked state will not reflect in the toggle switch.

Your Environment

  • Library: React
  • Version used: 16.12.0
  • Browser Name and version: Chrome
  • Operating System and version: macOS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant