In my scenario, I am trying to change the switch value on real time. Here, whenever the switch index value on/off changing componentWillReceiveProps
calling twice at a time. How to solve this issue?
My Code Below
componentWillReceiveProps(nextProps) { switch (this.state.selectedIndex) { case 0: if (nextProps.checkState.on) { this.setState({ switchValue: true }); } else { this.setState({ switchValue: false }); } break; default: this.setState({ switchValue: nextProps.checkState.on }); } }