update value
Hello! I would like to be able to update the value of the switch other than the initial value ("active" prop). My initial value comes from my state and when I change it I would like the component also to reflect the new value. I think it can be solved using componentDidUpdate which seems to be missing right now. I tried myself but the component got confused about its internal state and rendered incorrectly. I'm on v1.0.2.
Hi @maartenvandillen ,
Thanks for the input, yes you are right, currently, we don't allow any value to update from outside during lifecycle of the component. Will update the component ASAP to allow the value changes from outside. Thanks.
@prsn thanks, that would be great! Any idea when this will be added?
It seems like this issue is still not solved. I solve the problem by adding a key to the toggle component to force re-render when the active state is changed.
The code would look like this:
<ToggleSwitch key={switch-state-${this.state.activeSwitch}...props/>} }