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

Toggle not changed after change initial state at run time. #71

Open
vinod-sl opened this issue Jan 7, 2021 · 3 comments
Open

Toggle not changed after change initial state at run time. #71

vinod-sl opened this issue Jan 7, 2021 · 3 comments

Comments

@vinod-sl
Copy link

vinod-sl commented Jan 7, 2021

whenever i changed initial on the basis of my return success failure response then background color change but toggle not change its position. it appears right side always.
initial={isUpdated?1:0}

Toggle changed when we manually click on it if changed during run state changed it only change colors not toggle actually.

@Liip3Lim4
Copy link

Same error here, even changing initial and value properties with conditional values linked to states, the component don't change selected item visually.

@frk2
Copy link

frk2 commented Apr 30, 2021

Worked for me if I set value. Initial also has to be set to something though

@parmarkamlesh
Copy link

@vinod-sl you are just using normal variable. which runtime change wont affect component. so use state variable like this.
Update both values at same time from state.
Demo

   constructor(){
        super()
        this.state={
            time:0
        }       
    }
    componentDidMount(){
        setTimeout(()=>{
            this.setState({time:1})
        },2000)
        
    }
  <SwitchSelector
      ...
     initial={this.state.time}
     value={this.state.time}
     ... 
   />

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

4 participants