momentum-design/momentum-ui

ToggleSwitch Component is not updated based on the checked prop

Hkbm77 opened this issue · 0 comments

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